mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Use a transcript when generating the per-chain binding for a given set of keys
While it was fine as-is, as it only had one variable length property, this is a bit more robust. Also binds the Curve ID, which should declare differently even for just different basepoints, and therefore adds two variable length properties (justifying the transcript).
This commit is contained in:
@@ -8,7 +8,7 @@ pub use merlin::MerlinTranscript;
|
||||
use digest::Digest;
|
||||
|
||||
pub trait Transcript {
|
||||
fn domain_separate(&mut self, label: &[u8]);
|
||||
fn domain_separate(&mut self, label: &'static [u8]);
|
||||
fn append_message(&mut self, label: &'static [u8], message: &[u8]);
|
||||
fn challenge(&mut self, label: &'static [u8]) -> Vec<u8>;
|
||||
fn rng_seed(&mut self, label: &'static [u8]) -> [u8; 32];
|
||||
@@ -24,15 +24,12 @@ impl<D: Digest> PartialEq for DigestTranscript<D> {
|
||||
}
|
||||
|
||||
impl<D: Digest> DigestTranscript<D> {
|
||||
pub fn new(label: Vec<u8>) -> Self {
|
||||
DigestTranscript(label, PhantomData)
|
||||
pub fn new(label: &'static [u8]) -> Self {
|
||||
DigestTranscript(label.to_vec(), PhantomData)
|
||||
}
|
||||
}
|
||||
|
||||
impl<D: Digest> Transcript for DigestTranscript<D> {
|
||||
// It may be beneficial for each domain to be a nested transcript which is itself length prefixed
|
||||
// This would go further than Merlin though and require an accurate end_domain function which has
|
||||
// frustrations not worth bothering with when this shouldn't actually be meaningful
|
||||
fn domain_separate(&mut self, label: &[u8]) {
|
||||
self.append_message(b"domain", label);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user