Skip to content

Commit

Permalink
Challenge in accumulation mode
Browse files Browse the repository at this point in the history
  • Loading branch information
davxy committed Mar 26, 2024
1 parent e9782f9 commit c90acce
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ark-transcript/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ impl Mode {
println!("Shake128 {}transcript XoF reader",self.debug_name);
match self {
Mode::Hash(hasher) => Reader(hasher.clone().finalize_xof()),
Mode::Accumulate(_) => panic!("Attempt to read from accumulating Transcript"),
Mode::Accumulate(acc) => {
let mut t = Transcript::from_accumulation(acc);
t.seperate();
t.mode.raw_reader()
}
}
}
}
Expand Down
23 changes: 23 additions & 0 deletions ark-transcript/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,26 @@ fn accumulation() {
let c2: [u8; 32] = t3.challenge(b"challenge").read_byte_array();
assert_eq!(c1,c2);
}

#[test]
fn challenge_in_accumulation() {
let mut t1 = Transcript::new_blank_accumulator();
let mut t2 = Transcript::new_blank_accumulator();

let commitment1 = b"commitment data 1";
let commitment2 = b"commitment data 2";

t1.write_bytes(commitment1);
t2.write_bytes(commitment1);

t1.write_bytes(commitment2);
t2.write_bytes(commitment2);

let acc = t2.accumulator_finalize();
let mut t3 = Transcript::from_accumulation(acc);

let c1: [u8; 32] = t1.challenge(b"challenge").read_byte_array();
let c2: [u8; 32] = t3.challenge(b"challenge").read_byte_array();

assert_eq!(c1, c2);
}

0 comments on commit c90acce

Please sign in to comment.