mirror of
https://github.com/logos-co/nomos-pocs.git
synced 2025-01-11 09:56:11 +00:00
Use basepoint as the blinding point (#31)
This commit is contained in:
parent
9541c4b34d
commit
8870a32cbe
@ -10,7 +10,6 @@ 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"
|
||||||
|
@ -1,15 +1,9 @@
|
|||||||
use curve25519_dalek::{ristretto::RistrettoPoint, traits::VartimeMultiscalarMul, Scalar};
|
use curve25519_dalek::{ristretto::RistrettoPoint, Scalar};
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use rand_core::CryptoRngCore;
|
use rand_core::CryptoRngCore;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::NoteWitness;
|
use crate::NoteWitness;
|
||||||
|
|
||||||
lazy_static! {
|
|
||||||
// Precompute of ``
|
|
||||||
static ref PEDERSON_COMMITMENT_BLINDING_POINT: RistrettoPoint = crate::crypto::hash_to_curve(b"NOMOS_CL_PEDERSON_COMMITMENT_BLINDING");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[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);
|
||||||
|
|
||||||
@ -56,10 +50,7 @@ impl BalanceWitness {
|
|||||||
pub fn balance(value: u64, unit: Unit, blinding: Scalar) -> Unit {
|
pub fn balance(value: u64, unit: Unit, blinding: Scalar) -> Unit {
|
||||||
let value_scalar = Scalar::from(value);
|
let value_scalar = Scalar::from(value);
|
||||||
// can vartime leak the number of cycles through the stark proof?
|
// can vartime leak the number of cycles through the stark proof?
|
||||||
RistrettoPoint::vartime_multiscalar_mul(
|
RistrettoPoint::vartime_double_scalar_mul_basepoint(&value_scalar, &unit, &blinding)
|
||||||
&[value_scalar, blinding],
|
|
||||||
&[unit, *PEDERSON_COMMITMENT_BLINDING_POINT],
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@ -67,17 +58,6 @@ mod test {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::note::unit_point;
|
use crate::note::unit_point;
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_pederson_blinding_point_pre_compute() {
|
|
||||||
// use k256::elliptic_curve::group::GroupEncoding;
|
|
||||||
// println!("{:?}", <[u8;33]>::from((*PEDERSON_COMMITMENT_BLINDING_POINT).to_bytes()));
|
|
||||||
|
|
||||||
assert_eq!(
|
|
||||||
*PEDERSON_COMMITMENT_BLINDING_POINT,
|
|
||||||
crate::crypto::hash_to_curve(b"NOMOS_CL_PEDERSON_COMMITMENT_BLINDING")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_balance_zero_unitless() {
|
fn test_balance_zero_unitless() {
|
||||||
// Zero is the same across all units
|
// Zero is the same across all units
|
||||||
|
Loading…
x
Reference in New Issue
Block a user