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