precompute blinding point

This commit is contained in:
Giacomo Pasini 2024-08-19 16:30:26 +02:00
parent 9541c4b34d
commit f294efd1fe
No known key found for this signature in database
GPG Key ID: FC08489D2D895D4B
2 changed files with 26 additions and 8 deletions

View File

@ -10,7 +10,10 @@ serde = {version="1.0", features = ["derive"]}
group = "0.13.0" group = "0.13.0"
rand = "0.8.5" rand = "0.8.5"
rand_core = "0.6.0" rand_core = "0.6.0"
lazy_static = "1.4.0"
hex = "0.4.3" hex = "0.4.3"
curve25519-dalek = {version = "4.1", features = ["serde", "digest", "rand_core"]} curve25519-dalek = {version = "4.1", features = ["serde", "digest", "rand_core"]}
sha2 = "0.10" sha2 = "0.10"
once_cell = "1.8.0"
[patch.crates-io]
curve25519-dalek = { git = "https://github.com/risc0/curve25519-dalek", tag = "curve25519-4.1.2-risczero.0" }

View File

@ -1,14 +1,29 @@
use curve25519_dalek::{ristretto::RistrettoPoint, traits::VartimeMultiscalarMul, Scalar}; use curve25519_dalek::{
use lazy_static::lazy_static; ristretto::{CompressedRistretto, RistrettoPoint},
traits::VartimeMultiscalarMul,
Scalar,
};
use once_cell::sync::Lazy;
use rand_core::CryptoRngCore; use rand_core::CryptoRngCore;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::NoteWitness; use crate::NoteWitness;
// Precompute of 'crate::crypto::hash_to_curve(b"NOMOS_CL_PEDERSON_COMMITMENT_BLINDING")'
lazy_static! { pub static PEDERSON_COMMITMENT_BLINDING_POINT: Lazy<RistrettoPoint> = Lazy::new(|| {
// Precompute of `` let res = CompressedRistretto::from_slice(&[
static ref PEDERSON_COMMITMENT_BLINDING_POINT: RistrettoPoint = crate::crypto::hash_to_curve(b"NOMOS_CL_PEDERSON_COMMITMENT_BLINDING"); 194, 113, 61, 46, 252, 245, 84, 140, 48, 142, 70, 139, 136, 59, 43, 66, 72, 107, 86, 62,
} 159, 223, 229, 53, 73, 152, 89, 13, 152, 73, 150, 117,
])
.unwrap()
.decompress()
.unwrap();
// Precompute of 'crate::crypto::hash_to_curve(b"NOMOS_CL_PEDERSON_COMMITMENT_BLINDING")'
debug_assert_eq!(
res,
crate::crypto::hash_to_curve(b"NOMOS_CL_PEDERSON_COMMITMENT_BLINDING")
);
res
});
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)] #[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
pub struct Balance(pub RistrettoPoint); pub struct Balance(pub RistrettoPoint);