Uncomment level and bucket checks

This commit is contained in:
Vecna 2024-01-17 17:41:53 -05:00
parent a20300ab62
commit 1dbc14d5f1
1 changed files with 26 additions and 44 deletions

View File

@ -43,7 +43,6 @@ pub struct Request {
CBlockages: RistrettoPoint,
CQ: RistrettoPoint,
/*
// Fields for proving which bucket we have
H: RistrettoPoint,
BP: RistrettoPoint,
@ -51,7 +50,6 @@ pub struct Request {
// Fields for proving 3 <= trust_level <= 4
// CG can be computed by verifier
CGsq: RistrettoPoint,
*/
// The combined lox_zkp
piUser: CompactProof,
@ -61,11 +59,11 @@ define_proof! {
requestproof,
"Positive Report Request",
(id, bucket, level, since, invremain, blockages,
zid, zbucket, zlevel, zsince, zinvremain, zblockages, negzQ),
// g, zg, wg, yg),
zid, zbucket, zlevel, zsince, zinvremain, zblockages, negzQ,
g, zg, wg, yg),
(P, CId, CBucket, CLevel, CSince, CInvRemain, CBlockages,
V, Xid, Xbucket, Xlevel, Xsince, Xinvremain, Xblockages),
// H, BP, CG, CGsq),
V, Xid, Xbucket, Xlevel, Xsince, Xinvremain, Xblockages,
H, BP, CG, CGsq),
(A):
// Blind showing of the Lox credential
CId = (id*P + zid*A),
@ -74,33 +72,29 @@ define_proof! {
CSince = (since*P + zsince*A),
CInvRemain = (invremain*P + zinvremain*A),
CBlockages = (blockages*P + zblockages*A),
V = (zid*Xid + zbucket*Xbucket + zlevel*Xlevel + zsince*Xsince + zinvremain*Xinvremain + zblockages*Xblockages + negzQ*A)
/*
V = (zid*Xid + zbucket*Xbucket + zlevel*Xlevel + zsince*Xsince + zinvremain*Xinvremain + zblockages*Xblockages + negzQ*A),
// Prove bucket is same bucket used in BP
BP = (bucket*H),
// Prove CLevel encodes a value of 3 or 4
// First prove g is a bit by proving that g = g^2
CG = (g*P + zg*A), CGsq = (g*CG + wg*A), CGsq = (g*P + yg*A)
// The verifier will compute CG = CLevel - 3P
*/
}
pub fn request(
lox_cred: &cred::Lox,
lox_pub: &IssuerPubKey,
) -> Result<Request, ProofError> {
pub fn request(lox_cred: &cred::Lox, lox_pub: &IssuerPubKey) -> Result<Request, ProofError> {
let A: &RistrettoPoint = &CMZ_A;
let Atable: &RistrettoBasepointTable = &CMZ_A_TABLE;
/*
// TODO: Where should this go? For efficiency, this should probably be global
let today: u32 = time::OffsetDateTime::now_utc().date()
let today: u32 = time::OffsetDateTime::now_utc()
.date()
.to_julian_day()
.try_into()
.unwrap();
let H: RistrettoPoint = RistrettoPoint::hash_from_bytes::<Sha512>(format!("PR Generator H for {}",today).as_bytes());
let H: RistrettoPoint = RistrettoPoint::hash_from_bytes::<Sha512>(
format!("PR Generator H for {}", today).as_bytes(),
);
let Htable: RistrettoBasepointTable = RistrettoBasepointTable::create(&H);
*/
// Ensure that the credential can be correctly shown: it must be the case
// that trust_level is 3 or 4
@ -151,7 +145,6 @@ pub fn request(
+ zblockages * lox_pub.X[6]
+ &negzQ * Atable;
/*
// Compute BP for proving knowledge of bucket
let BP = &lox_cred.bucket * &Htable;
@ -175,7 +168,6 @@ pub fn request(
let CG = g * P + &zg * Atable;
let CGsq = g * P + &yg * Atable;
*/
// Construct the proof
let mut transcript = Transcript::new(b"positive report request");
@ -197,12 +189,10 @@ pub fn request(
Xsince: &lox_pub.X[4],
Xinvremain: &lox_pub.X[5],
Xblockages: &lox_pub.X[6],
/*
H: &H,
BP: &BP,
CG: &CG,
CGsq: &CGsq,
*/
id: &lox_cred.id,
bucket: &lox_cred.bucket,
level: &lox_cred.trust_level,
@ -216,34 +206,28 @@ pub fn request(
zinvremain: &zinvremain,
zblockages: &zblockages,
negzQ: &negzQ,
/*
g: &g,
zg: &zg,
wg: &wg,
yg: &yg,
*/
},
)
.0;
Ok(
Request {
P,
CId,
CBucket,
CLevel,
CSince,
CInvRemain,
CBlockages,
CQ,
/*
H,
BP,
CGsq,
*/
piUser,
}
)
Ok(Request {
P,
CId,
CBucket,
CLevel,
CSince,
CInvRemain,
CBlockages,
CQ,
H,
BP,
CGsq,
piUser,
})
}
impl BridgeAuth {
@ -268,7 +252,7 @@ impl BridgeAuth {
- req.CQ;
// Recompute CG
// let CG = req.CLevel - Scalar::from(3 as u8) * req.P;
let CG = req.CLevel - Scalar::from(3 as u8) * req.P;
// Verify the zkp
let mut transcript = Transcript::new(b"positive report request");
@ -291,12 +275,10 @@ impl BridgeAuth {
Xsince: &self.lox_pub.X[4].compress(),
Xinvremain: &self.lox_pub.X[5].compress(),
Xblockages: &self.lox_pub.X[6].compress(),
/*
H: &req.H.compress(),
BP: &req.BP.compress(),
CG: &CG.compress(),
CGsq: &req.CGsq.compress(),
*/
},
)?;