Skip to content

Commit 4badf67

Browse files
Adam GibsonAdam Gibson
Adam Gibson
authored and
Adam Gibson
committed
include user label as message in audit
1 parent e430be0 commit 4badf67

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

auditor-docs/README.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,17 @@ target/release/autct -M serve -k mycontext:something.pks -n signet
3434
But use the `auditprove` method from the client:
3535

3636
```
37-
target/release/autct -M auditprove -k mycontext:something.pks -n signet -H 127.0.0.1 -i some-privkeys.txt --audit-range-min 5000 --audit-range-exponent 12
37+
target/release/autct -M auditprove -k mycontext:something.pks \
38+
-n signet -H 127.0.0.1 -i some-privkeys.txt \
39+
--audit-range-min 5000 --audit-range-exponent 12 \
40+
-u "Alice's more than 5K sats"
3841
```
3942

40-
First note the two new option flags ``--audit-range-min`` which corresponds to \(k\) in the description, and ``-audit-range-exponent`` which corresponds to \(n\). Second, the format of `some-privkeys.txt` is like this:
43+
First note the two new option flags ``--audit-range-min`` which corresponds to $k$ in the description, and ``-audit-range-exponent`` which corresponds to $n$.
44+
45+
Second the argument ``-u`` is necessary here: it functions exactly as the "message" in a Schnorr signature, evidencing what is attested to. Otherwise, someone could take your proof of funds and use it to pretend they owned the money! One sensible thing to put as the "message" here might be a public key, over which you could sign.
46+
47+
Thirdly, the format of `some-privkeys.txt` is like this:
4148

4249
```
4350
cMahea7zqjxrtgAbB7LSGbcQUr1uX1ojuat9jZodMN87Lc8ycuM4,5000
@@ -49,9 +56,11 @@ that is, it is pairs (raw WIF private key, value-in-sats) one per line, remember
4956
To verify an existing proof file, you need to know what ``audit-range-min`` and ``audit-range-exponent`` are being claimed (for now; this is actually in the proof serialization so it can be extracted), and run the `auditverify` method:
5057

5158
```
52-
target/release/autct -M auditverify -k mycontext:something.pks -n signet -H 127.0.0.1 -P some-proof.txt --audit-range-min 5000 --audit-range-exponent 12
59+
target/release/autct -M auditverify -k mycontext:something.pks -n signet -H 127.0.0.1 -P some-proof.txt --audit-range-min 5000 --audit-range-exponent 12 -u "Alice's more than 5K sats"
5360
```
5461

62+
Note that you need to use exactly the same message as `-u` here as in proving, also.
63+
5564
If successful, the following will be printed:
5665

5766
```

src/auditor.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ ScalarField = P0::BaseField> + Copy,> AuditProof<F, P0, P1> {
109109
// proof parameters:
110110
keyset: &str,
111111
curve_tree: &CurveTree<P0, P1>,
112-
sr_params: &SelRerandParameters<P0, P1>
112+
sr_params: &SelRerandParameters<P0, P1>,
113+
user_string: &str
113114
) -> Result<AuditProof<F, P0, P1>, Box<dyn Error>> {
114115
// 3: curve tree proof for each of the m commitments
115116
let mut curvetree_p0_proofs: Vec<R1CSProof<Affine<P0>>> = Vec::new();
@@ -210,7 +211,7 @@ ScalarField = P0::BaseField> + Copy,> AuditProof<F, P0, P1> {
210211
&basesvec,
211212
keyimagebase,
212213
// TODO labelling:
213-
b"bloo",b"blah"));
214+
b"bloo", user_string.as_bytes()));
214215
}
215216
// We now have a full set of AuditProof elements:
216217
Ok(AuditProof{
@@ -232,7 +233,8 @@ ScalarField = P0::BaseField> + Copy,> AuditProof<F, P0, P1> {
232233
pub fn verify(
233234
&self, G: &Affine<P0>, J: &Affine<P0>,
234235
curve_tree: &CurveTree<P0, P1>,
235-
sr_params: &SelRerandParameters<P0, P1>
236+
sr_params: &SelRerandParameters<P0, P1>,
237+
user_string: &str
236238
) -> Result<(), Box<dyn Error>>
237239
{
238240
// Before verifying the ZK proofs,
@@ -260,7 +262,7 @@ ScalarField = P0::BaseField> + Copy,> AuditProof<F, P0, P1> {
260262
&vec![self.blinded_commitment_list[i], self.Q_comms[i]],
261263
&basesvec,
262264
b"bloo", // TODO labels
263-
b"blah"
265+
user_string.as_bytes()
264266
)?;
265267
}
266268
for i in 0..m {

src/lib.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ pub mod rpc {
251251
values,
252252
&pva.keyset_file_locs[0],
253253
&pva.curve_trees[0],
254-
&pva.sr_params
254+
&pva.sr_params,
255+
&args.user_label
255256
).unwrap(); // todo Result not working?
256257
//if prfres.is_err(){
257258
// resp.accepted = -2;
@@ -263,7 +264,8 @@ pub mod rpc {
263264
//
264265
let verifresult = prf.verify(&G, &J,
265266
&pva.curve_trees[0], // assuming one is that OK? TODO
266-
&pva.sr_params);
267+
&pva.sr_params,
268+
&args.user_label);
267269
if verifresult.is_err() {
268270
resp.accepted = -2;
269271
return Ok(resp);
@@ -617,7 +619,8 @@ pub mod rpc {
617619
// uses one keyset in the definition, hence [0]:
618620
let verifresult = prf.verify(&G, &J,
619621
&pva.curve_trees[0],
620-
&pva.sr_params);
622+
&pva.sr_params,
623+
&verif_request.user_label);
621624
if verifresult.is_err() {
622625
resp.accepted = -3;
623626
return Ok(resp);

0 commit comments

Comments
 (0)