You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-5Lines changed: 33 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -899,8 +899,8 @@ should be used while encryption, decryption, proving and verification (as shown
899
899
For signers (issuers of credentials), it's important to encode attributes that need to be verifiably encoded using a reversible
900
900
encoding as the decryption might happen much later than the proof verification and thus the decryptor should be able to independently
901
901
recover the actual attributes. This situation is different from selective disclosure where the actual attributes are given to the
902
-
verifier who can then encode the attributes before verifying the proof. One such pair of functions are `Signature.reversibleEncodeStringMessageForSigning`
903
-
and `Signature.reversibleDecodeStringMessageForSigning` and you can see its use in the above-mentioned test.
902
+
verifier who can then encode the attributes before verifying the proof. One such pair of functions are `Signature.reversibleEncodeStringForSigning`
903
+
and `Signature.reversibleDecodeStringForSigning` and you can see its use in the above-mentioned test.
904
904
905
905
For creating the proof of knowledge of the BBS+ signature and verifiably encrypting an attribute, the prover creates the following 2 statements.
906
906
@@ -1228,9 +1228,37 @@ For complete example, see [these tests](./tests/composite-proofs/bound-check.spe
1228
1228
1229
1229
### Working with messages as JS objects
1230
1230
1231
-
The above interfaces have been found to be a bit difficult to work with when signing messages that are represented as JS objects.
1232
-
[Here](./src/sign-verify-js-objs.ts) are some [utilities](./src/bbs-plus/encoder.ts) to make this task a bit easier. [The tests here](tests/composite-proofs/msg-js-obj) contain
1233
-
plenty of examples.
1231
+
The above interfaces have been found to be a bit difficult to work with when signing messages/credentials that are represented as JS objects like
1232
+
1233
+
```json
1234
+
{
1235
+
"fname": "John",
1236
+
"lname": "Smith",
1237
+
"sensitive": {
1238
+
"secret": "my-secret-that-wont-tell-anyone",
1239
+
"email": "john.smith@example.com",
1240
+
"SSN": "123-456789-0",
1241
+
"user-id": "user:123-xyz-#"
1242
+
},
1243
+
"location": {
1244
+
"country": "USA",
1245
+
"city": "New York"
1246
+
},
1247
+
"timeOfBirth": 1662010849619,
1248
+
"physical": {
1249
+
"height": 181.5,
1250
+
"weight": 210,
1251
+
"BMI": 23.25
1252
+
},
1253
+
"score": -13.5
1254
+
}
1255
+
```
1256
+
1257
+
[Here](./src/sign-verify-js-objs.ts) are some utilities to make this task a bit easier. The idea is to flatten the JSON, sort the keys alphabetically
1258
+
to have a list with deterministic order and then use the [encoder](./src/bbs-plus/encoder.ts) to encode each value as a field element (a number between 0 and another large number).
1259
+
The encoder can be configured to use different encoding functions for different keys to convert values from different types
1260
+
like string, positive or negative integers or decimal numbers to field elements.
1261
+
[The tests here](tests/composite-proofs/msg-js-obj) contain plenty of examples.
0 commit comments