pluto / ronkathon

Cryptography Educational Foundations
https://pluto.xyz/blog/ronkathon-learn-cryptography-from-first-principles
Apache License 2.0
192 stars 24 forks source link

feat: fiat shamir transcript #121

Open devloper opened 4 months ago

devloper commented 4 months ago

universal transcript, support for various hashing techniques.

lonerapier commented 4 months ago

Been looking into this, and studying existing libraries, there are two possible conclusions, either implement a byte-oriented transcript based on Keccak or Blake3 (or other byte-oriented hash functions).

trait Hasher {
    fn hash(&mut self, &[u8], buf: &mut [u8]);
}

pub struct Transcript<H: Hasher> {
    state: Vec<u8>,
}

impl Transcript {
    fn add_message(&mut self, message: &[u8]);
    fn create_challenge(&self, buf: &mut [u8]);
}

pub trait ByteHandler<C> {
    fn from_bytes(bytes: &[u8]) -> C;
    fn to_bytes(c: &C, buf: &mut [u8]);
}

or a field-oriented based on algebraic hash functions like Poseidon. Maybe use SAFE API for designing the sponge.

Need inputs of which way do you think is more suitable for a universal transcript. Am i missing something, or is there any other way you think this can be implemented?