update pedersen hash example to use constant inputs

This commit is contained in:
collin 2021-03-22 15:24:32 -07:00
parent b5ae4e1ca4
commit ae9ba51b7d
3 changed files with 9 additions and 5 deletions

View File

@ -60,7 +60,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> ConstrainedProgram<'a, F, G> {
)?)),
Type::Array(type_, len) => self.allocate_array(cs, name, &*type_, *len, input_option, span),
Type::Tuple(types) => self.allocate_tuple(cs, &name, types, input_option, span),
_ => unimplemented!("main function input not implemented for type {}", type_),
_ => unimplemented!("main function input not implemented for type {}", type_), // Todo @damirka: add an error for this case
}
}
}

View File

@ -1,4 +1,8 @@
[main]
hash_input: [bool; 256] = [true; 256];
[constants]
parameters: [group; 256] = [1group; 256];
[registers]
r0: group = (1, 0)group;

View File

@ -18,10 +18,10 @@ circuit PedersenHash {
}
// The 'pedersen-hash' main function.
function main() -> group {
let parameters = [1group; 256];
function main(hash_input: [bool; 256], const parameters: [group; 256]) -> group {
let pedersen = PedersenHash::new(parameters);
let hash_input: [bool; 256] = [true; 256];
return pedersen.hash(hash_input)
let output = pedersen.hash(hash_input);
console.log("{}", output);
return output
}