diff --git a/scripts/1_load_identities.sh b/scripts/1_load_identities.sh index 55083cb..78d0b3c 100755 --- a/scripts/1_load_identities.sh +++ b/scripts/1_load_identities.sh @@ -5,40 +5,40 @@ emma=$(curl -s http://localhost:9010/v1/self -H 'accept: application/json' | jq reginald=$(curl -s http://localhost:9020/v1/self -H 'accept: application/json' | jq -r .address) # First persona (Heidi the Hydrogen Producer) -curl -X 'PUT' http://localhost:9000/v1/members/$heidi \ +curl -s -X 'PUT' http://localhost:9000/v1/members/$heidi \ -H 'Content-Type: application/json' \ - -d '{"alias":"Heidi"}' + -d '{"alias":"Heidi"}' | jq -r -curl -X 'PUT' http://localhost:9000/v1/members/$emma \ +curl -s -X 'PUT' http://localhost:9000/v1/members/$emma \ -H 'Content-Type: application/json' \ - -d '{"alias": "Emma"}' + -d '{"alias": "Emma"}' | jq -r -curl -X 'PUT' http://localhost:9000/v1/members/$reginald \ +curl -s -X 'PUT' http://localhost:9000/v1/members/$reginald \ -H 'Content-Type: application/json' \ - -d '{"alias": "Reginald"}' + -d '{"alias": "Reginald"}' | jq -r # Second persona (Emma the Energy Producer) -curl -X 'PUT' http://localhost:9010/v1/members/$heidi \ +curl -s -X 'PUT' http://localhost:9010/v1/members/$heidi \ -H 'Content-Type: application/json' \ - -d '{"alias":"Heidi"}' + -d '{"alias":"Heidi"}' | jq -r -curl -X 'PUT' http://localhost:9010/v1/members/$emma \ +curl -s -X 'PUT' http://localhost:9010/v1/members/$emma \ -H 'Content-Type: application/json' \ - -d '{"alias": "Emma"}' + -d '{"alias": "Emma"}' | jq -r -curl -X 'PUT' http://localhost:9010/v1/members/$reginald \ +curl -s -X 'PUT' http://localhost:9010/v1/members/$reginald \ -H 'Content-Type: application/json' \ - -d '{"alias": "Reginald"}' + -d '{"alias": "Reginald"}' | jq -r # Third persona (Reginald the Regulator) -curl -X 'PUT' http://localhost:9020/v1/members/$heidi \ +curl -s -X 'PUT' http://localhost:9020/v1/members/$heidi \ -H 'Content-Type: application/json' \ - -d '{"alias":"Heidi"}' + -d '{"alias":"Heidi"}' | jq -r -curl -X 'PUT' http://localhost:9020/v1/members/$emma \ +curl -s -X 'PUT' http://localhost:9020/v1/members/$emma \ -H 'Content-Type: application/json' \ - -d '{"alias": "Emma"}' + -d '{"alias": "Emma"}' | jq -r -curl -X 'PUT' http://localhost:9020/v1/members/$reginald \ +curl -s -X 'PUT' http://localhost:9020/v1/members/$reginald \ -H 'Content-Type: application/json' \ - -d '{"alias": "Reginald"}' \ No newline at end of file + -d '{"alias": "Reginald"}' | jq -r \ No newline at end of file diff --git a/scripts/5_revoke_certificate.sh b/scripts/5_revoke_certificate.sh new file mode 100755 index 0000000..47f3874 --- /dev/null +++ b/scripts/5_revoke_certificate.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +# Run script using 'source ./5_revoke_certificate.sh' or '. ./5_revoke_certificate.sh' + +reggie_response=$(curl -s -X 'GET' http://localhost:8020/v1/certificate -H 'accept: application/json') + +export reggie_local_id=$(echo $reggie_response | jq -r '.[] | .id') + +echo "Reginald the Regulator submits the documentation explaining the grounds for revocation" + +file_id=$(curl -s -X 'POST' http://localhost:8020/v1/attachment \ + -H 'accept: application/json' \ + -H 'Content-Type: multipart/form-data' \ + -F 'file=@Revocation_Reason.pdf;type=application/pdf' | jq -r .id) + +sleep 2 + +echo "Reginald the Regulator now revokes the certificate" + +revoked_cert=$(curl -s -X 'POST' http://localhost:8020/v1/certificate/$reggie_local_id/revocation \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -d '{ + "reason": "'"$file_id"'" +}') + +sleep 1 + +echo "Waiting for certificate to be revoked on-chain" + +state=$(curl -s http://localhost:8020/v1/certificate/$reggie_local_id -H 'accept: application/json' | jq -r .state) + +while [ "$state" != "revoked" ] +do +sleep 2 +state=$(curl -s http://localhost:8020/v1/certificate/$reggie_local_id -H 'accept: application/json' | jq -r .state) +echo $state +done + +echo "The final certificate as seen by the Regulator" + +curl -s http://localhost:8020/v1/certificate/$reggie_local_id -H 'accept: application/json' | jq -r \ No newline at end of file diff --git a/scripts/Revocation_Reason.pdf b/scripts/Revocation_Reason.pdf new file mode 100644 index 0000000..baf5669 Binary files /dev/null and b/scripts/Revocation_Reason.pdf differ diff --git a/scripts/basic-demo.md b/scripts/basic-demo.md index 520167d..93edf62 100644 --- a/scripts/basic-demo.md +++ b/scripts/basic-demo.md @@ -91,4 +91,17 @@ You will first check that this additional private data matches against that whic You will then add the eCO2 to the `initialised` certificate on the ledger and the final certificate will be `issued`. -Run `. ./4_add_eCO2.sh` \ No newline at end of file +Run `. ./4_add_eCO2.sh` + + +### 5. Revoke the certificate + +Reginald the Regulator has identified a problem with this hydrogen certificate. The reasons for revocation are contained within the PDF document titled `Revocation_Reason.pdf`. + +Inform the audience that Reginald will first upload the document explaining the grounds for revocation into the system, and then trigger the revocation of the certificate. + +This revocation will then be finalised by the shared `ledger` so that both the reason and revocation are visible by all. + +Run `. ./5_revoke_certificate.sh` + +It is important to state that the system is designed like this to prevent revocation from happening without a reason first being given and indelibly linked to the certificate that it is revoking. \ No newline at end of file