mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-18 15:31:32 +03:00
27 lines
683 B
Plaintext
27 lines
683 B
Plaintext
circuit PedersenHash {
|
|
parameters: [group; 256],
|
|
|
|
// Instantiates a Pedersen hash circuit
|
|
function new(self, parameters: [group; 256]) -> Self {
|
|
return Self { parameters: parameters }
|
|
}
|
|
|
|
function hash(bits: [bool; 256]) -> group {
|
|
let mut digest: group = 0;
|
|
for i in 0..256 {
|
|
if bits[i] {
|
|
digest += self.parameters[i];
|
|
}
|
|
}
|
|
return digest
|
|
}
|
|
}
|
|
|
|
// The 'pedersen-hash' main function.
|
|
function main() -> group {
|
|
let parameters = [1group; 256];
|
|
let pedersen = PedersenHash::new(parameters);
|
|
let hash_input: [bool; 256] = [true; 256];
|
|
return pedersen.hash(hash_input)
|
|
}
|