Redesign macro to use || as separator

This commit is contained in:
Thomas Eizinger 2021-05-11 14:21:28 +10:00
parent cf32828739
commit 52939ad217
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96
2 changed files with 19 additions and 26 deletions

View File

@ -45,7 +45,10 @@ pub fn sign(
pseudo_output_commitment,
msg,
);
let h_0 = hash_to_scalar!(prefix, L_0.compress(), R_0.compress());
let L_0 = L_0.compress();
let R_0 = R_0.compress();
let h_0 = hash_to_scalar!(prefix || L_0 || R_0);
let h_last = fake_responses
.iter()
@ -54,10 +57,10 @@ pub fn sign(
let pk_i = ring[i + 1];
let adjusted_commitment_i = commitment_ring[i] - pseudo_output_commitment;
let L_i = compute_L(h_prev, &mus, *s_i, pk_i, adjusted_commitment_i);
let R_i = compute_R(h_prev, &mus, pk_i, *s_i, I, D_inv_8);
let L_i = compute_L(h_prev, &mus, *s_i, pk_i, adjusted_commitment_i).compress();
let R_i = compute_R(h_prev, &mus, pk_i, *s_i, I, D_inv_8).compress();
hash_to_scalar!(prefix, L_i.compress(), R_i.compress())
hash_to_scalar!(prefix || L_i || R_i)
});
let s_last = alpha - h_last * ((mus.mu_P * signing_key) + (mus.mu_C * z));
@ -114,10 +117,10 @@ pub fn verify(
);
let adjusted_commitment_i = commitment_ring[i] - pseudo_output_commitment;
let L_i = compute_L(h, &mus, *s_i, pk_i, adjusted_commitment_i);
let R_i = compute_R(h, &mus, pk_i, *s_i, sig.I, sig.D);
let L_i = compute_L(h, &mus, *s_i, pk_i, adjusted_commitment_i).compress();
let R_i = compute_R(h, &mus, pk_i, *s_i, sig.I, sig.D).compress();
h = hash_to_scalar!(prefix, L_i.compress(), R_i.compress())
h = hash_to_scalar!(prefix || L_i || R_i)
}
h == sig.h_0
@ -207,24 +210,14 @@ impl AggregationHashes {
pseudo_output_commitment: CompressedEdwardsY,
D: CompressedEdwardsY,
) -> Self {
let mu_P = hash_to_scalar!(
b"CLSAG_agg_0",
ring,
commitment_ring,
I,
D,
pseudo_output_commitment
);
let mu_C = hash_to_scalar!(
b"CLSAG_agg_1",
ring,
commitment_ring,
I,
D,
pseudo_output_commitment
);
Self { mu_P, mu_C }
Self {
mu_P: hash_to_scalar!(
b"CLSAG_agg_0" || ring || commitment_ring || I || D || pseudo_output_commitment
),
mu_C: hash_to_scalar!(
b"CLSAG_agg_1" || ring || commitment_ring || I || D || pseudo_output_commitment
),
}
}
}

View File

@ -2,7 +2,7 @@ use crate::ring::Ring;
use curve25519_dalek::edwards::CompressedEdwardsY;
macro_rules! hash_to_scalar {
($($e:expr),+) => {
($($e:tt) || +) => {
{
use crate::macros::AsByteSlice as _;