Skip to content

Commit

Permalink
docs: write documentation for BBS signature
Browse files Browse the repository at this point in the history
docs: added examples in BBS page

docs: added zkp in BBS page

docs: good overall BBS documentation

docs: BBS bats files now produce the scripts in docs

docs: removed unused files

docs: final adjustments BBS page links

docs: bbs added issuer keys generation
  • Loading branch information
Luckydd99 authored and albertolerda committed May 15, 2023
1 parent 6f9caec commit 1518f72
Show file tree
Hide file tree
Showing 24 changed files with 540 additions and 34 deletions.
2 changes: 1 addition & 1 deletion docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
- [Scenario 'credentials': zero knowledge proof and attribute based credentials](/pages/zencode-scenario-credentials.md "Zencode credentials")
- [Scenario 'ecdh': encryption, signature](/pages/zencode-scenarios-ecdh "Zencode ecdh")
- [Scenario 'eddsa': signature](/pages/zencode-scenarios-eddsa "Zencode eddsa")
- [Scenario 'bbs': signature](/pages/zencode-scenarios-bbs "Zencode BBS")
- [Scenario 'bbs': signature, zero knowledge proof](/pages/zencode-scenarios-bbs "Zencode BBS")
- [Scenario 'petition': cryptographic petition](/pages/zencode-scenarios-petition "Zencode petition")
- [Scenario 'dp3t': proximity tracing](/pages/zencode-scenario-dp3t "Zencode dp3t")
- [Scenario 'secshare': secret sharing](/pages/zencode-scenario-secShare "Zencode secret share")
Expand Down
1 change: 1 addition & 0 deletions docs/examples/zencode_cookbook/bbs/alice_keys_docs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Alice":{"keyring":{"bbs":"U+KhGohqd4/Cs1dA/6HBj3wOM8vSgEQ++1wVcTaKFZ0="}}}
1 change: 1 addition & 0 deletions docs/examples/zencode_cookbook/bbs/alice_pubkey_docs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Alice":{"bbs_public_key":"qZAXFyd/GWAv9WQllN9t+w+6AlMAfjrb4RXhmYP0wGRzUpR1VBQwTzwdr2UvdxTvFBjxVb6TF7ZPK1B6qji08gLlioiMLO/0cBBRZrnsTRhynsDXlB6Yp6brQ758zqFj"}}
18 changes: 18 additions & 0 deletions docs/examples/zencode_cookbook/bbs/create_credential_docs.zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Scenario 'bbs': authority generates the private credential

Given I am 'The Authority'
and I have my 'keyring'

Given I have a 'string array' named 'bbs messages'

# The hash function used to generate the signature, to create the proof and to verify it
# must be the same in all the three cases.
Given I have a 'string' named 'hash name'

# The private credential is generated by signing the messages.
When I create the bbs signature of 'bbs messages' using 'hash name'
When I rename the 'bbs signature' to 'bbs credential'

Then print the 'bbs messages'
Then print the 'bbs credential'
Then print the 'hash name'
28 changes: 28 additions & 0 deletions docs/examples/zencode_cookbook/bbs/create_proof_docs.zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Scenario 'bbs': participant generates the bbs proof

Given I have a 'bbs public key' inside 'The Authority'
Given I have a 'bbs credential'
Given I have a 'string array' named 'bbs messages'
# This is the same hash function used by the Authority to sign the messages.
Given I have a 'string' named 'hash name'

Given I have a 'number array' named 'bbs disclosed indexes'

When I create the random object of '256' bits
When I rename the 'random_object' to 'bbs presentation header'

When I create the bbs disclosed messages

# The SAME hash function must be used in BOTH the creation and the verification.
When I create the bbs proof of the signature 'bbs credential' of the messages 'bbs messages' using 'hash name' with public key 'bbs public key' presentation header 'bbs presentation header' and disclosed indexes 'bbs disclosed indexes'
When I rename the 'bbs proof' to 'bbs proof verbose'
When I create the bbs proof using 'hash name'

Then print the 'bbs proof verbose'
Then print the 'bbs proof'
Then print the 'bbs public key'
Then print the 'bbs disclosed messages'
Then print the 'bbs disclosed indexes'
Then print the 'bbs presentation header'
Then print the 'bbs credential'
Then print the 'hash name'
1 change: 1 addition & 0 deletions docs/examples/zencode_cookbook/bbs/created_proof_docs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"bbs_credential":"mM+sPY0BNTri66IFR/G9HgSvJuzhf1fz36twKO4RnQXQyKYv2afPYa0J7fKpGC2KSdUb4M9lC59iLXS5n6Cutgc8pE21NRyvaV/Pp3mOnOxSw8ScbPbpuQuPVqUkPK16V+hlWMKRVc7+njxQZUt1oA==","bbs_disclosed_indexes":[1,3],"bbs_disclosed_messages":["above 18","professor"],"bbs_presentation_header":"XdjAYj+RY95+uyYMI8fR3+fmP5LyQaN54vyTTVKxZyA=","bbs_proof":"txtzTP3STsaGXlm/VtIChwy8EsnAGvpgV2sNVHm0Muiml0aUOZU6Exh1wCFo2tn7rhWn1AKQdiX6ZUzdz/X3FRbSYbg6J1zDK1989WFmsb2h174KiGUpTWcX6hnurJW1qpfT+GZjLZDc7LoAQlVjZ4SShg26A7AmckR21ZAZ8qKPE6eBEuAhA/bxfWBsJaCxHYFi7T6PQn3HU2g9ZafMUdWhnzszbkNu32uGlnSKPR5rR6GNnCUwiVlBZoDCHZpB0nGPXFTQB+FVKiEQuae9niMJuSKEbFGpT7fWFs6MLeXJbnbfCw5OJ/Rk3EZzGti3UUGXW5Xmke/WXqOD0pwYB7FeraPlM4f2LRxSTXgL/9Vd9QB3OK8gcvX+8xZyji4lRmEbLXeuk79H4bqs8j5jgkjJqQJYqZnqZ8FIdW6SsUJtFZ0gVCTWrXfssw9rBVkl","bbs_proof_verbose":"tcIqOLqAfzb20nvreTgXFCVon32VG8alqu+f3GBeq7787ibrpOh4RrUF13bcpam5g0QwTsqI14t7eIEkLMZJwbZb/KJz2XdVnu1A3dlJ0urNoTKo/O3XSgTl+0PiJqS3tsNzQi0mhA2rHnc7iJNc7g/rx4HoRc8LvZfb6TuusFxt51+SvN8ywREpyBIYMf57Jgs9m1uy8RMfaZ8GG8zPhK3A2yjCofp69t20pvBezRIMyGBZ7qlMZsWiMaKYG+83CwOiDHNupPe3EhEgiqaTZBVJqMcV0K912aWZ55kRDOW2/47cuTwE2QrPNbGrL3/eG78U8vIeepjUvLl6IKHlTw4Hk+dMa+XGrVyZFEUwcvNsA28ocVKI7wW6NJuxfQpXl3ViGIIS3IYOYdU+y/PrmEa7hXoQKE1pTWzPz9/uIXEm1l3ij+jTRlWi7/VgV/35","bbs_public_key":"o+JuJ0zDfbRzXkXsgBZ9t2YvM+OGOFWqByaQeYxplqUU/2SNEYTcP5QQh1mSN9xxDyNW/s6Lm/fR8D6c7kfbdRwSPcx+xb0iemsNxhwFtVqo/KrAtpsOaBugtUh8P0xY","hash_name":"sha256"}
14 changes: 14 additions & 0 deletions docs/examples/zencode_cookbook/bbs/data_credential_docs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"The_Authority": {
"bbs_public_key": "o+JuJ0zDfbRzXkXsgBZ9t2YvM+OGOFWqByaQeYxplqUU/2SNEYTcP5QQh1mSN9xxDyNW/s6Lm/fR8D6c7kfbdRwSPcx+xb0iemsNxhwFtVqo/KrAtpsOaBugtUh8P0xY",
"keyring": {
"bbs": "MXuDMAavZ9URy0VSwIxQwl9gCTXL1ePQfyWpHQCL9Wk="
}
},
"bbs_messages": [
"above 18",
"italian",
"professor"
],
"hash_name": "sha256"
}
10 changes: 10 additions & 0 deletions docs/examples/zencode_cookbook/bbs/issuer_keys_docs.zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Scenario 'bbs': authority generates its keys

Given I am 'The Authority'

When I create the bbs key
When I create the bbs public key

Then print my 'bbs public key'
Then print my 'keyring'

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"The_Authority":{"bbs_public_key":"qZAXFyd/GWAv9WQllN9t+w+6AlMAfjrb4RXhmYP0wGRzUpR1VBQwTzwdr2UvdxTvFBjxVb6TF7ZPK1B6qji08gLlioiMLO/0cBBRZrnsTRhynsDXlB6Yp6brQ758zqFj","keyring":{"bbs":"U+KhGohqd4/Cs1dA/6HBj3wOM8vSgEQ++1wVcTaKFZ0="}}}
5 changes: 5 additions & 0 deletions docs/examples/zencode_cookbook/bbs/keygen_docs.zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Scenario bbs
Given I am known as 'Alice'
When I create the keyring
and I create the bbs key
Then print my 'keyring'
8 changes: 8 additions & 0 deletions docs/examples/zencode_cookbook/bbs/messages_docs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"myMessage": "Dear Bob, your name is too short, goodbye - Alice.",
"myStringArray": [
"Hello World! This is my string array, element [0]",
"Hello World! This is my string array, element [1]",
"Hello World! This is my string array, element [2]"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"bbs_credential":"mM+sPY0BNTri66IFR/G9HgSvJuzhf1fz36twKO4RnQXQyKYv2afPYa0J7fKpGC2KSdUb4M9lC59iLXS5n6Cutgc8pE21NRyvaV/Pp3mOnOxSw8ScbPbpuQuPVqUkPK16V+hlWMKRVc7+njxQZUt1oA==","bbs_messages":["above 18","italian","professor"],"hash_name":"sha256"}
16 changes: 16 additions & 0 deletions docs/examples/zencode_cookbook/bbs/proof_data_docs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"The_Authority": {
"bbs_public_key": "o+JuJ0zDfbRzXkXsgBZ9t2YvM+OGOFWqByaQeYxplqUU/2SNEYTcP5QQh1mSN9xxDyNW/s6Lm/fR8D6c7kfbdRwSPcx+xb0iemsNxhwFtVqo/KrAtpsOaBugtUh8P0xY"
},
"bbs_credential": "mM+sPY0BNTri66IFR/G9HgSvJuzhf1fz36twKO4RnQXQyKYv2afPYa0J7fKpGC2KSdUb4M9lC59iLXS5n6Cutgc8pE21NRyvaV/Pp3mOnOxSw8ScbPbpuQuPVqUkPK16V+hlWMKRVc7+njxQZUt1oA==",
"bbs_messages": [
"above 18",
"italian",
"professor"
],
"hash_name": "sha256",
"bbs_disclosed_indexes": [
1,
3
]
}
17 changes: 17 additions & 0 deletions docs/examples/zencode_cookbook/bbs/proved_signature_docs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"The_Authority": {
"bbs_public_key": "o+JuJ0zDfbRzXkXsgBZ9t2YvM+OGOFWqByaQeYxplqUU/2SNEYTcP5QQh1mSN9xxDyNW/s6Lm/fR8D6c7kfbdRwSPcx+xb0iemsNxhwFtVqo/KrAtpsOaBugtUh8P0xY"
},

"bbs_disclosed_indexes": [
1,
3
],
"bbs_disclosed_messages": [
"above 18",
"professor"
],
"bbs_presentation_header": "4rAHPkKy0JmKDC4klGayzHvSqqDxMWyJ61SvkmiAHjU=",
"bbs_proof": "hjaff22+6VybKCyVBA6EQCndmPA3G/EGADBSe2jJys50GX9RKM87U0PRd+JlJDQemBpb1r0R4cvWRIFWJdFV01PGEH+prkmhkS5fTgbNsU4wnLayrjAVALr74FWzTbf1luwfzk2rRABZ+5xzEuP/pf6qkwRmYFZpcYJzaWODyRV6dSinfYAbFOmHD42xfPGbTYtEFznPdlo0vlgUM6YQYH360yx1P1iybdlbJCoPUdZdA/DCtK/mjEJ+PuMJ1nXQmGoWJ7hfB2mD9pcHSNmFH0zzMmjJ1q98kK2EeaMcqVsY2iHiDoqrTxyaka8QLvzMCvtN34bvg0fO7o8pzVfJLqWa6zQRJgwel2WtgbEcjAJfFmkOoa9O0aancWOPOAiMlDwFtSIU9tvchDDPEUVVjHBZyETlsEwm/JTmVGOMZtMUuxrlJy4RvF0aqNSpRqKX",
"hash_name": "sha256"
}
5 changes: 5 additions & 0 deletions docs/examples/zencode_cookbook/bbs/pubkey_docs.zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Scenario bbs
Given I am known as 'Alice'
Given I have my 'keyring'
When I create the bbs public key
Then print my 'bbs public key'
27 changes: 27 additions & 0 deletions docs/examples/zencode_cookbook/bbs/sign_bbs_docs.zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Scenario 'bbs': create the signature of an object
Given I am 'Alice'
Given I have my 'keyring'
Given I have a 'string' named 'myMessage'
Given I have a 'string array' named 'myStringArray'

When I create the bbs signature of 'myStringArray'
When I rename the 'bbs signature' to 'myStringArray.signature'

When I create the bbs signature of 'myMessage'
When I rename the 'bbs signature' to 'myMessage.signature'

#If we want we can specify the hash function used by the algorithm

When I create the bbs signature of 'myStringArray' using 'sha256'
When I rename the 'bbs signature' to 'myStringArray.signature.sha'

When I create the bbs signature of 'myMessage' using 'sha256'
When I rename the 'bbs signature' to 'myMessage.signature.sha'

# Here we are printing out the signatures
Then print the 'myStringArray'
Then print the 'myStringArray.signature'
Then print the 'myStringArray.signature.sha'
Then print the 'myMessage'
Then print the 'myMessage.signature'
Then print the 'myMessage.signature.sha'
1 change: 1 addition & 0 deletions docs/examples/zencode_cookbook/bbs/signed_bbs_docs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"myMessage":"Dear Bob, your name is too short, goodbye - Alice.","myMessage.signature":"phrA6Z73Pte6tP1hRCAbFWE6Qe/2C3+p0fcSkQVP9q0/N+zoXRhxSimVNF0V9WSpAByW8j2ns+4v2kPIX3GoF2AtwBhJyi0Joez2zMcRnc8YU81TR2FJ9dXrqKcl3hGbPcNlVu0dARF70UyW3ty+sg==","myMessage.signature.sha":"rkV1JhqPBXS2oQLTnzIduBKohQbrIk/4prfyRtVCnU5utcMVxdOEzGzoT3lPgXFEPEDTrqM7XiAm0cNdZWcqIMrQlMeluQ0T72WxssR3+jMgbgpO8bBSPQE9vXTp7GCyRdruSU42C3K5uIOowyfGAQ==","myStringArray":["Hello World! This is my string array, element [0]","Hello World! This is my string array, element [1]","Hello World! This is my string array, element [2]"],"myStringArray.signature":"o/ikYoogxAULnuPPqZZ2VeJRRT1pwH68DF1IG5GfeVp6wEObW8bnXkKVpUDs+2NUSCRZeZDqRTCqQO5/4stA52gTOZBULpgH3jFdygSxM+EOVQfEB3I2Vgaeo+BkqCsJZwd1G6qmCUXsipfzd2oxaA==","myStringArray.signature.sha":"irOL3GN7pfdbTA3IslZjWv1S4PGnkZfKcGgOhybPd3dnTNWknoVD+UuS15taRLySGxMDa3mptbdibW9Q0wSnhHiyLjsGVxUQTipYbAlQikQQTdH9eGDeMPkm40ghbRkFhyHsAuR4q7+nbMbwZbPEAA=="}
1 change: 1 addition & 0 deletions docs/examples/zencode_cookbook/bbs/verified_bbs_docs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"myMessage":"Dear Bob, your name is too short, goodbye - Alice.","myStringArray":["Hello World! This is my string array, element [0]","Hello World! This is my string array, element [1]","Hello World! This is my string array, element [2]"],"output":["Zenroom_certifies_that_signatures_are_all_correct!"]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"output":["bbs_zkp_verification_successful"]}
29 changes: 29 additions & 0 deletions docs/examples/zencode_cookbook/bbs/verify_bbs_docs.zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Scenario 'bbs': Bob verifies the signature from Alice

# Here we load the pubkey we'll verify the signature against
Given I have a 'bbs public key' from 'Alice'

# Here we load the objects to be verified
Given I have a 'string' named 'myMessage'
Given I have a 'string array' named 'myStringArray'

# Here we load the objects' signatures
Given I have a 'bbs signature' named 'myStringArray.signature'
Given I have a 'bbs signature' named 'myMessage.signature'
Given I have a 'bbs signature' named 'myStringArray.signature.sha'
Given I have a 'bbs signature' named 'myMessage.signature.sha'

# Here we perform the verifications.
# When not specified, the bbs verification algorithm uses SHAKE-256.
When I verify the 'myMessage' has a bbs signature in 'myMessage.signature' by 'Alice'
When I verify the 'myStringArray' has a bbs signature in 'myStringArray.signature' by 'Alice'

# You can specify either 'SHA256' or 'SHAKE256' as input like this:
When I verify the 'myMessage' has a bbs signature in 'myMessage.signature.sha' by 'Alice' using 'sha256'
When I verify the 'myStringArray' has a bbs signature in 'myStringArray.signature.sha' by 'Alice' using 'sha256'

# Here we print out the result: if the verifications succeeded, a string will be printed out
# If the verifications failed, Zenroom will throw an error.
Then print the string 'Zenroom certifies that signatures are all correct!'
Then print the 'myMessage'
Then print the 'myStringArray'
15 changes: 15 additions & 0 deletions docs/examples/zencode_cookbook/bbs/verify_proof_docs.zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Scenario bbs: verify a bbs proof

# We load al the necessary objects one at a time
Given I have a 'bbs public key' in 'The Authority'
and I have a 'bbs proof'
and I have a 'base64' named 'bbs presentation header'
Given I have a 'number array' named 'bbs disclosed indexes'
and I have a 'string array' named 'bbs disclosed messages'

# The SAME hash function must be used in BOTH the creation and the verification.
When I verify the bbs proof using 'sha256' with public key 'bbs public key' presentation header 'bbs presentation header' disclosed messages 'bbs disclosed messages' and disclosed indexes 'bbs disclosed indexes'
When I verify the bbs proof using 'sha256'

# The print is executed only if the verification was successful
Then print the string 'bbs zkp verification successful'
Loading

0 comments on commit 1518f72

Please sign in to comment.