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:
Luke Parker
2022-06-03 01:37:12 -04:00
parent 44452d9bfe
commit e4fc469e58
8 changed files with 20 additions and 23 deletions

View File

@@ -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);
}

View File

@@ -10,7 +10,7 @@ impl Debug for MerlinTranscript {
}
impl Transcript for MerlinTranscript {
fn domain_separate(&mut self, label: &[u8]) {
fn domain_separate(&mut self, label: &'static [u8]) {
self.append_message(b"dom-sep", label);
}