2020-05-20 22:45:40 +03:00
|
|
|
circuit PedersenHash {
|
|
|
|
parameters: group[512]
|
|
|
|
|
|
|
|
static function new(parameters: group[512]) -> Self {
|
|
|
|
return Self { parameters: parameters }
|
|
|
|
}
|
|
|
|
|
|
|
|
function hash(bits: bool[512]) -> group {
|
|
|
|
let mut digest: group = 0;
|
|
|
|
|
|
|
|
for i in 0..512 {
|
|
|
|
let base = if bits[i] ? parameters[i] : 0;
|
|
|
|
digest += base;
|
|
|
|
}
|
|
|
|
|
|
|
|
return digest
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-15 23:38:07 +03:00
|
|
|
function main(parameters: group[512]) -> group {
|
2020-05-20 22:45:40 +03:00
|
|
|
let pedersen = PedersenHash::new(parameters);
|
|
|
|
|
|
|
|
let input: bool[512] = [true; 512]; // use mock private key until `.bits()` function is implemented
|
|
|
|
let output = pedersen.hash(input);
|
|
|
|
|
|
|
|
return output
|
|
|
|
}
|