Only return first state element from Poseidon hash
Co-authored-by: str4d <jack@z.cash>
This commit is contained in:
parent
25f5ccd445
commit
bb16eca2c0
|
@ -17,6 +17,7 @@ def perm(input_words):
|
|||
round_constants_counter = 0
|
||||
|
||||
state_words = list(input_words)
|
||||
assert len(state_words) == t
|
||||
|
||||
# First full rounds
|
||||
for r in range(0, R_f):
|
||||
|
@ -313,7 +314,7 @@ def main():
|
|||
|
||||
render_tv(
|
||||
render_args(),
|
||||
'poseidon_perm',
|
||||
'orchard_poseidon',
|
||||
(
|
||||
('input', '[[u8; 32]; 3]'),
|
||||
('output', '[[u8; 32]; 3]'),
|
||||
|
|
|
@ -10,7 +10,7 @@ CAPACITY_ELEMENT = Fp(1 << 65)
|
|||
def poseidon_hash(x, y):
|
||||
assert isinstance(x, Fp)
|
||||
assert isinstance(y, Fp)
|
||||
return perm([x, y, CAPACITY_ELEMENT])
|
||||
return perm([x, y, CAPACITY_ELEMENT])[0]
|
||||
|
||||
def main():
|
||||
test_vectors = [[Fp.ZERO, Fp(1)]]
|
||||
|
@ -33,14 +33,14 @@ def main():
|
|||
|
||||
render_tv(
|
||||
render_args(),
|
||||
'poseidon_hash',
|
||||
'orchard_poseidon_hash',
|
||||
(
|
||||
('input', '[[u8; 32]; 2]'),
|
||||
('output', '[[u8; 32]; 3]'),
|
||||
('output', '[u8; 32]'),
|
||||
),
|
||||
[{
|
||||
'input': list(map(bytes, input)),
|
||||
'output': list(map(bytes, poseidon_hash(input[0], input[1]))),
|
||||
'output': bytes(poseidon_hash(input[0], input[1])),
|
||||
} for input in test_vectors],
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue