Skip to content
This repository was archived by the owner on Oct 1, 2025. It is now read-only.

Commit bb59343

Browse files
authored
feat: did sign (#93)
Allow issuers to sign on verifiable document directly * chore: update packages & npm audit fix * feat: did signing implementation * fix: integration test for did signing Co-authored-by: Raymond Yeh <ray@geek.sg>
1 parent 1d02a42 commit bb59343

14 files changed

Lines changed: 1964 additions & 902 deletions

File tree

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,14 @@ open-attestation document-store verify --document ./examples/wrapped-documents/e
224224
✔ success The document is valid
225225
```
226226
227+
## DID Direct Signing
228+
229+
Sign on an OA document directly with a private key.
230+
231+
```bash
232+
open-attestation sign ./examples/unsigned-documents -f ./examples/sample-key -p did:ethr:0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69#controller --output-dir ./examples/signed-documents
233+
```
234+
227235
## DNS TXT record
228236
229237
Create a temporary DNS TXT record in OpenAttestation sandbox
@@ -328,6 +336,7 @@ open-attestation encrypt
328336
open-attestation filter
329337
open-attestation verify
330338
open-attestation wrap
339+
open-attestation sign
331340
```
332341
333342
## Test

examples/sample-key

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0000000000000000000000000000000000000000000000000000000000000003
1+
0x0000000000000000000000000000000000000000000000000000000000000003

examples/signed-documents/did.json

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"version": "https://schema.openattestation.com/2.0/schema.json",
3+
"data": {
4+
"id": "612c5be7-5c5e-4a97-80e0-a4f22aae99b9:string:SGCNM21566325",
5+
"$template": {
6+
"name": "7eb859a2-9e07-4ebc-885e-1b06446f3c79:string:CERTIFICATE_OF_NON_MANIPULATION",
7+
"type": "6e632c44-01cd-4bf8-8fd1-97598aa09a1b:string:EMBEDDED_RENDERER",
8+
"url": "ec77d855-e745-491b-95df-f5856f76620a:string:https://demo-cnm.openattestation.com"
9+
},
10+
"issuers": [
11+
{
12+
"id": "a31d9016-30ff-4302-bdaa-d7c97fe51006:string:did:ethr:0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69",
13+
"name": "40fcded0-a474-4dca-a423-e7a5cd417137:string:DEMO STORE",
14+
"revocation": {
15+
"type": "ef6e7855-bdb5-47ad-b2cc-1c250b4e6087:string:NONE"
16+
},
17+
"identityProof": {
18+
"type": "80ec5301-2b9a-471a-b9be-573a3ed35dcc:string:DID",
19+
"key": "eaa434a8-09f8-4c65-9de2-d94c2bd2770a:string:did:ethr:0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69#controller"
20+
}
21+
}
22+
],
23+
"recipient": {
24+
"name": "6dade7f3-6316-455e-ae8c-1a8ac4cdd032:string:SG FREIGHT",
25+
"address": {
26+
"street": "22426f1a-5f5d-4f0b-af8e-124a4b00c4f7:string:101 ORCHARD ROAD",
27+
"country": "7df1f46b-1731-4e85-86f8-3e86a5bab5c5:string:SINGAPORE"
28+
}
29+
},
30+
"consignment": {
31+
"description": "fd554eda-40b7-4f86-a00e-557517998998:string:16667 CARTONS OF RED WINE",
32+
"quantity": {
33+
"value": "759aea31-c5c2-470b-b4b6-85b6f77cb04b:number:5000",
34+
"unit": "88795b1b-4115-4215-a921-5bd6f1b8870f:string:LITRES"
35+
},
36+
"countryOfOrigin": "34da0086-9673-43e9-aa6e-a1c6c412abcb:string:AUSTRALIA",
37+
"outwardBillNo": "15265fe8-ce8c-49c5-85db-8f19212925b9:string:AQSIQ170923130",
38+
"dateOfDischarge": "55d26f4a-22df-43a9-b801-463cf0c5538c:string:2018-01-26",
39+
"dateOfDeparture": "9299b829-c0e7-4d86-acb9-695f6aab1e81:string:2018-01-30",
40+
"countryOfFinalDestination": "325e534e-b7ad-4a12-91af-e22c703c3535:string:CHINA",
41+
"outgoingVehicleNo": "1b09f8fa-c428-412f-be84-1c50cb7700fc:string:COSCO JAPAN 074E/30-JAN"
42+
},
43+
"declaration": {
44+
"name": "9611e74f-d526-4526-b772-088bf2806ddd:string:PETER LEE",
45+
"designation": "5eab92ac-820f-4ebd-a77a-5e54f44213e7:string:SHIPPING MANAGER",
46+
"date": "9463885c-1833-427c-af3a-7a7f24bc391f:string:2018-01-28"
47+
}
48+
},
49+
"signature": {
50+
"type": "SHA3MerkleProof",
51+
"targetHash": "0ff2bee4bc5e0cde00dbf4524ca5173724538e3bf46241ff653e07ae51141c4d",
52+
"proof": [],
53+
"merkleRoot": "0ff2bee4bc5e0cde00dbf4524ca5173724538e3bf46241ff653e07ae51141c4d"
54+
},
55+
"proof": [
56+
{
57+
"type": "OpenAttestationSignature2018",
58+
"created": "2020-10-05T09:05:35.171Z",
59+
"proofPurpose": "assertionMethod",
60+
"verificationMethod": "did:ethr:0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69#controller",
61+
"signature": "0x6d0ff5c64b8230cdc471f38267495002f2c762acf7a80250599809ee32b4255377f1adcb56fb712dee66bfeb21be6b5d802f299aea1f1edca129e88e4c1742ce1c"
62+
}
63+
]
64+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"version": "https://schema.openattestation.com/2.0/schema.json",
3+
"data": {
4+
"id": "3280e86b-4caa-4243-b2d0-c5fa02189fe5:string:SGCNM21566325",
5+
"$template": {
6+
"name": "ade6c04b-84ff-4fae-9c92-913c60ce2991:string:CERTIFICATE_OF_NON_MANIPULATION",
7+
"type": "9ac8bc3b-f036-4e49-80b9-645e22059996:string:EMBEDDED_RENDERER",
8+
"url": "8fb2c9c4-a20c-4bf4-b639-bf3af16a6ec7:string:https://demo-cnm.openattestation.com"
9+
},
10+
"issuers": [
11+
{
12+
"id": "0fea2337-fd03-430c-8f03-f008dd92f156:string:did:ethr:0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69",
13+
"name": "1ec2e081-e108-4435-9f8a-120d53de89f0:string:DEMO STORE",
14+
"revocation": {
15+
"type": "9eac45c9-06d6-4f83-ba20-0f4c7b55452f:string:NONE"
16+
},
17+
"identityProof": {
18+
"type": "2c5c6fe5-5061-4aac-8035-fe4d2f210862:string:DNS-DID",
19+
"key": "a51ab9e9-7b1b-458b-ab88-455e694975f7:string:did:ethr:0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69#controller",
20+
"location": "bb241fcf-11fa-4607-aa73-dfc86fefaa68:string:donotverify.testing.openattestation.com"
21+
}
22+
}
23+
],
24+
"recipient": {
25+
"name": "0151d7dc-3a80-4f45-b302-bfd9f13cfe59:string:SG FREIGHT",
26+
"address": {
27+
"street": "2c0935eb-ee9b-417d-81aa-6c30c2394245:string:101 ORCHARD ROAD",
28+
"country": "15dfddf5-5776-4232-88b9-7c8c08f5fd1c:string:SINGAPORE"
29+
}
30+
},
31+
"consignment": {
32+
"description": "c4f245cf-7255-4fd2-a1b8-b6ad766fe56d:string:16667 CARTONS OF RED WINE",
33+
"quantity": {
34+
"value": "013be6b5-cabd-42c2-b5b3-90a05e34366c:number:5000",
35+
"unit": "96d4e88a-0db3-4dd0-b4f1-d24cb93a9ea5:string:LITRES"
36+
},
37+
"countryOfOrigin": "e5ff63f1-74d4-4f7e-b5a4-d89f62d6b2dd:string:AUSTRALIA",
38+
"outwardBillNo": "0fc1e46f-30af-4ff1-bcdf-fe6307f7bd18:string:AQSIQ170923130",
39+
"dateOfDischarge": "43caa208-843c-4963-baf9-6a449a929c52:string:2018-01-26",
40+
"dateOfDeparture": "c3b3e65a-9162-4658-864c-f5f6a1e8d485:string:2018-01-30",
41+
"countryOfFinalDestination": "cf1b625b-f33b-4886-b7cb-2349e4ce88da:string:CHINA",
42+
"outgoingVehicleNo": "7db188ee-68f8-4f29-9531-d11ea8ecca21:string:COSCO JAPAN 074E/30-JAN"
43+
},
44+
"declaration": {
45+
"name": "1db3a389-0053-4b59-a8a1-19e8ed53a55b:string:PETER LEE",
46+
"designation": "9ccc4931-265f-4977-8a85-559287f44dc2:string:SHIPPING MANAGER",
47+
"date": "a12d3d74-888b-44a4-9c4d-77a738bcf5d4:string:2018-01-28"
48+
}
49+
},
50+
"signature": {
51+
"type": "SHA3MerkleProof",
52+
"targetHash": "12e27173dcef6761c3eaa31a4a23412412e314abaec790eef1706e752fb8d51f",
53+
"proof": [],
54+
"merkleRoot": "12e27173dcef6761c3eaa31a4a23412412e314abaec790eef1706e752fb8d51f"
55+
},
56+
"proof": [
57+
{
58+
"type": "OpenAttestationSignature2018",
59+
"created": "2020-10-05T09:05:35.171Z",
60+
"proofPurpose": "assertionMethod",
61+
"verificationMethod": "did:ethr:0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69#controller",
62+
"signature": "0x04b56b7a8405364cc925143c2fc28f91ee7a3e340402ba66e616f275110cbc446e140716f88f418581e02a371d246e1b98f07c937ee9b96d7bc8aebb470345c71b"
63+
}
64+
]
65+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"version": "https://schema.openattestation.com/2.0/schema.json",
3+
"data": {
4+
"id": "612c5be7-5c5e-4a97-80e0-a4f22aae99b9:string:SGCNM21566325",
5+
"$template": {
6+
"name": "7eb859a2-9e07-4ebc-885e-1b06446f3c79:string:CERTIFICATE_OF_NON_MANIPULATION",
7+
"type": "6e632c44-01cd-4bf8-8fd1-97598aa09a1b:string:EMBEDDED_RENDERER",
8+
"url": "ec77d855-e745-491b-95df-f5856f76620a:string:https://demo-cnm.openattestation.com"
9+
},
10+
"issuers": [
11+
{
12+
"id": "a31d9016-30ff-4302-bdaa-d7c97fe51006:string:did:ethr:0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69",
13+
"name": "40fcded0-a474-4dca-a423-e7a5cd417137:string:DEMO STORE",
14+
"revocation": {
15+
"type": "ef6e7855-bdb5-47ad-b2cc-1c250b4e6087:string:NONE"
16+
},
17+
"identityProof": {
18+
"type": "80ec5301-2b9a-471a-b9be-573a3ed35dcc:string:DID",
19+
"key": "eaa434a8-09f8-4c65-9de2-d94c2bd2770a:string:did:ethr:0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69#controller"
20+
}
21+
}
22+
],
23+
"recipient": {
24+
"name": "6dade7f3-6316-455e-ae8c-1a8ac4cdd032:string:SG FREIGHT",
25+
"address": {
26+
"street": "22426f1a-5f5d-4f0b-af8e-124a4b00c4f7:string:101 ORCHARD ROAD",
27+
"country": "7df1f46b-1731-4e85-86f8-3e86a5bab5c5:string:SINGAPORE"
28+
}
29+
},
30+
"consignment": {
31+
"description": "fd554eda-40b7-4f86-a00e-557517998998:string:16667 CARTONS OF RED WINE",
32+
"quantity": {
33+
"value": "759aea31-c5c2-470b-b4b6-85b6f77cb04b:number:5000",
34+
"unit": "88795b1b-4115-4215-a921-5bd6f1b8870f:string:LITRES"
35+
},
36+
"countryOfOrigin": "34da0086-9673-43e9-aa6e-a1c6c412abcb:string:AUSTRALIA",
37+
"outwardBillNo": "15265fe8-ce8c-49c5-85db-8f19212925b9:string:AQSIQ170923130",
38+
"dateOfDischarge": "55d26f4a-22df-43a9-b801-463cf0c5538c:string:2018-01-26",
39+
"dateOfDeparture": "9299b829-c0e7-4d86-acb9-695f6aab1e81:string:2018-01-30",
40+
"countryOfFinalDestination": "325e534e-b7ad-4a12-91af-e22c703c3535:string:CHINA",
41+
"outgoingVehicleNo": "1b09f8fa-c428-412f-be84-1c50cb7700fc:string:COSCO JAPAN 074E/30-JAN"
42+
},
43+
"declaration": {
44+
"name": "9611e74f-d526-4526-b772-088bf2806ddd:string:PETER LEE",
45+
"designation": "5eab92ac-820f-4ebd-a77a-5e54f44213e7:string:SHIPPING MANAGER",
46+
"date": "9463885c-1833-427c-af3a-7a7f24bc391f:string:2018-01-28"
47+
}
48+
},
49+
"signature": {
50+
"type": "SHA3MerkleProof",
51+
"targetHash": "0ff2bee4bc5e0cde00dbf4524ca5173724538e3bf46241ff653e07ae51141c4d",
52+
"proof": [],
53+
"merkleRoot": "0ff2bee4bc5e0cde00dbf4524ca5173724538e3bf46241ff653e07ae51141c4d"
54+
}
55+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"version": "https://schema.openattestation.com/2.0/schema.json",
3+
"data": {
4+
"id": "3280e86b-4caa-4243-b2d0-c5fa02189fe5:string:SGCNM21566325",
5+
"$template": {
6+
"name": "ade6c04b-84ff-4fae-9c92-913c60ce2991:string:CERTIFICATE_OF_NON_MANIPULATION",
7+
"type": "9ac8bc3b-f036-4e49-80b9-645e22059996:string:EMBEDDED_RENDERER",
8+
"url": "8fb2c9c4-a20c-4bf4-b639-bf3af16a6ec7:string:https://demo-cnm.openattestation.com"
9+
},
10+
"issuers": [
11+
{
12+
"id": "0fea2337-fd03-430c-8f03-f008dd92f156:string:did:ethr:0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69",
13+
"name": "1ec2e081-e108-4435-9f8a-120d53de89f0:string:DEMO STORE",
14+
"revocation": {
15+
"type": "9eac45c9-06d6-4f83-ba20-0f4c7b55452f:string:NONE"
16+
},
17+
"identityProof": {
18+
"type": "2c5c6fe5-5061-4aac-8035-fe4d2f210862:string:DNS-DID",
19+
"key": "a51ab9e9-7b1b-458b-ab88-455e694975f7:string:did:ethr:0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69#controller",
20+
"location": "bb241fcf-11fa-4607-aa73-dfc86fefaa68:string:donotverify.testing.openattestation.com"
21+
}
22+
}
23+
],
24+
"recipient": {
25+
"name": "0151d7dc-3a80-4f45-b302-bfd9f13cfe59:string:SG FREIGHT",
26+
"address": {
27+
"street": "2c0935eb-ee9b-417d-81aa-6c30c2394245:string:101 ORCHARD ROAD",
28+
"country": "15dfddf5-5776-4232-88b9-7c8c08f5fd1c:string:SINGAPORE"
29+
}
30+
},
31+
"consignment": {
32+
"description": "c4f245cf-7255-4fd2-a1b8-b6ad766fe56d:string:16667 CARTONS OF RED WINE",
33+
"quantity": {
34+
"value": "013be6b5-cabd-42c2-b5b3-90a05e34366c:number:5000",
35+
"unit": "96d4e88a-0db3-4dd0-b4f1-d24cb93a9ea5:string:LITRES"
36+
},
37+
"countryOfOrigin": "e5ff63f1-74d4-4f7e-b5a4-d89f62d6b2dd:string:AUSTRALIA",
38+
"outwardBillNo": "0fc1e46f-30af-4ff1-bcdf-fe6307f7bd18:string:AQSIQ170923130",
39+
"dateOfDischarge": "43caa208-843c-4963-baf9-6a449a929c52:string:2018-01-26",
40+
"dateOfDeparture": "c3b3e65a-9162-4658-864c-f5f6a1e8d485:string:2018-01-30",
41+
"countryOfFinalDestination": "cf1b625b-f33b-4886-b7cb-2349e4ce88da:string:CHINA",
42+
"outgoingVehicleNo": "7db188ee-68f8-4f29-9531-d11ea8ecca21:string:COSCO JAPAN 074E/30-JAN"
43+
},
44+
"declaration": {
45+
"name": "1db3a389-0053-4b59-a8a1-19e8ed53a55b:string:PETER LEE",
46+
"designation": "9ccc4931-265f-4977-8a85-559287f44dc2:string:SHIPPING MANAGER",
47+
"date": "a12d3d74-888b-44a4-9c4d-77a738bcf5d4:string:2018-01-28"
48+
}
49+
},
50+
"signature": {
51+
"type": "SHA3MerkleProof",
52+
"targetHash": "12e27173dcef6761c3eaa31a4a23412412e314abaec790eef1706e752fb8d51f",
53+
"proof": [],
54+
"merkleRoot": "12e27173dcef6761c3eaa31a4a23412412e314abaec790eef1706e752fb8d51f"
55+
}
56+
}

0 commit comments

Comments
 (0)