Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Employment authorization document test vector. #106

Merged
merged 5 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions TestVectors/eddsa-rdfc-2022/employ/canonDocDataInt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<did:key:zDnaegE6RR3atJtHKwTRTWHsJ3kNHqFwv7n9YjTgmU7TyfU76> <https://schema.org/image> <data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIW2NgUPr/HwADaAIhG61j/AAAAABJRU5ErkJggg==> .
_:c14n0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/citizenship#EmploymentAuthorizationDocumentCredential> .
_:c14n0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://www.w3.org/2018/credentials#VerifiableCredential> .
_:c14n0 <https://schema.org/description> "Example Country Employment Authorization Document." .
_:c14n0 <https://schema.org/name> "Employment Authorization Document" .
_:c14n0 <https://www.w3.org/2018/credentials#credentialSubject> _:c14n1 .
_:c14n0 <https://www.w3.org/2018/credentials#issuer> <did:key:zDnaegE6RR3atJtHKwTRTWHsJ3kNHqFwv7n9YjTgmU7TyfU76> .
_:c14n0 <https://www.w3.org/2018/credentials#validFrom> "2019-12-03T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
_:c14n0 <https://www.w3.org/2018/credentials#validUntil> "2029-12-03T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
_:c14n1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://schema.org/Person> .
_:c14n1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/citizenship#EmployablePerson> .
_:c14n1 <https://schema.org/additionalName> "JACOB" .
_:c14n1 <https://schema.org/birthDate> "1999-07-17"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
_:c14n1 <https://schema.org/familyName> "SMITH" .
_:c14n1 <https://schema.org/gender> "Male" .
_:c14n1 <https://schema.org/givenName> "JOHN" .
_:c14n1 <https://schema.org/image> <data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIW2Ng+M/wHwAEAQH/7yMK/gAAAABJRU5ErkJggg==> .
_:c14n1 <https://w3id.org/citizenship#birthCountry> "Bahamas" .
_:c14n1 <https://w3id.org/citizenship#employmentAuthorizationDocument> _:c14n2 .
_:c14n1 <https://w3id.org/citizenship#residentSince> "2015-01-01"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
_:c14n2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/citizenship#EmploymentAuthorizationDocument> .
_:c14n2 <https://schema.org/identifier> "83627465" .
_:c14n2 <https://w3id.org/citizenship#lprCategory> "C09" .
_:c14n2 <https://w3id.org/citizenship#lprNumber> "999-999-999" .
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bea7b7acfbad0126b135104024a5f1733e705108f42d59668b05c0c50004c6b0e21de16d0139192fe6ea51851d3bb55d55937eb88f80b7f3ba3b79af16bc643f
1 change: 1 addition & 0 deletions TestVectors/eddsa-rdfc-2022/employ/docHashDataInt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e21de16d0139192fe6ea51851d3bb55d55937eb88f80b7f3ba3b79af16bc643f
5 changes: 5 additions & 0 deletions TestVectors/eddsa-rdfc-2022/employ/proofCanonDataInt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
_:c14n0 <http://purl.org/dc/terms/created> "2023-02-24T23:36:38Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
_:c14n0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/security#DataIntegrityProof> .
_:c14n0 <https://w3id.org/security#cryptosuite> "eddsa-rdfc-2022"^^<https://w3id.org/security#cryptosuiteString> .
_:c14n0 <https://w3id.org/security#proofPurpose> <https://w3id.org/security#assertionMethod> .
_:c14n0 <https://w3id.org/security#verificationMethod> <did:key:z6MkrJVnaZkeFzdQyMZu1cgjg7k1pZZ6pvBQ7XJPt4swbTQ2#z6MkrJVnaZkeFzdQyMZu1cgjg7k1pZZ6pvBQ7XJPt4swbTQ2> .
11 changes: 11 additions & 0 deletions TestVectors/eddsa-rdfc-2022/employ/proofConfigDataInt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"type": "DataIntegrityProof",
"cryptosuite": "eddsa-rdfc-2022",
"created": "2023-02-24T23:36:38Z",
"verificationMethod": "did:key:z6MkrJVnaZkeFzdQyMZu1cgjg7k1pZZ6pvBQ7XJPt4swbTQ2#z6MkrJVnaZkeFzdQyMZu1cgjg7k1pZZ6pvBQ7XJPt4swbTQ2",
"proofPurpose": "assertionMethod",
"@context": [
"https://www.w3.org/ns/credentials/v2",
"https://w3id.org/citizenship/v4rc1"
]
}
1 change: 1 addition & 0 deletions TestVectors/eddsa-rdfc-2022/employ/proofHashDataInt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bea7b7acfbad0126b135104024a5f1733e705108f42d59668b05c0c50004c6b0
1 change: 1 addition & 0 deletions TestVectors/eddsa-rdfc-2022/employ/sigBTC58DataInt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
z64e3a7hAtYQ3pqCdBsPLRpNqJd5YTzbMP7WrotbqY7HtANPq3ZSYoycsz3tHxzqJM5GVR5bUk7TpjoxgdUDXMQaR
1 change: 1 addition & 0 deletions TestVectors/eddsa-rdfc-2022/employ/sigHexDataInt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fd390da7cb1fb09628217967dd67b0cbcc8fd00a9eb4f7cc90561b0695380b603d856b9663b53c69e78f4004b67e2d1b06a8dd00e424e779ff52203767f0840e
46 changes: 46 additions & 0 deletions TestVectors/eddsa-rdfc-2022/employ/signedDataInt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"@context": [
"https://www.w3.org/ns/credentials/v2",
"https://w3id.org/citizenship/v4rc1"
],
"type": [
"VerifiableCredential",
"EmploymentAuthorizationDocumentCredential"
],
"issuer": {
"id": "did:key:zDnaegE6RR3atJtHKwTRTWHsJ3kNHqFwv7n9YjTgmU7TyfU76",
"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIW2NgUPr/HwADaAIhG61j/AAAAABJRU5ErkJggg=="
},
"credentialSubject": {
"type": [
"Person",
"EmployablePerson"
],
"givenName": "JOHN",
"additionalName": "JACOB",
"familyName": "SMITH",
"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIW2Ng+M/wHwAEAQH/7yMK/gAAAABJRU5ErkJggg==",
"gender": "Male",
"residentSince": "2015-01-01",
"birthCountry": "Bahamas",
"birthDate": "1999-07-17",
"employmentAuthorizationDocument": {
"type": "EmploymentAuthorizationDocument",
"identifier": "83627465",
"lprCategory": "C09",
"lprNumber": "999-999-999"
}
},
"name": "Employment Authorization Document",
"description": "Example Country Employment Authorization Document.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"description": "Example Country Employment Authorization Document.",
"description": "Employment Authorization Document for Example Country.",

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or

Suggested change
"description": "Example Country Employment Authorization Document.",
"description": "Example Employment Authorization Document for Country.",

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TallTed, @dlongley or @msporny I took the unsigned inputs from the VC playground with some modifications (removed render method, substituted single pixel image for long PNG). Any changes to the input JSON file requires rerunning test vector generation code and changes derived/generated test vectors. Can folks come to an agreement on any changes to inputs (or not) then I will rerun the vectors.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with changing this description as @TallTed recommends.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well just simplify to Example Employment Authorization Document.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TallTed are you okay with @dlongley suggestion or your original suggestion. Let me know then I'll rerun the code to generate the test vectors.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the background on the language there is it started as "[Country Name] Employment Authorization Document". Some other examples we have would use "Utopia" there. Real country names would be similar. It wasn't originally intended to be "Example [Country Name] EAD", but I see how it looks like that now and is a bit awkward. It's only an example so hopefully anyone that copies whatever ends up here will adjust as needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK with @dlongley's simplification. It might be better to quote the identifier of the thing being modified by "Example", as --

Suggested change
"description": "Example Country Employment Authorization Document.",
"description": "Example \"Employment Authorization Document\".",

"validFrom": "2019-12-03T00:00:00Z",
"validUntil": "2029-12-03T00:00:00Z",
"proof": {
"type": "DataIntegrityProof",
"cryptosuite": "eddsa-rdfc-2022",
"created": "2023-02-24T23:36:38Z",
"verificationMethod": "did:key:z6MkrJVnaZkeFzdQyMZu1cgjg7k1pZZ6pvBQ7XJPt4swbTQ2#z6MkrJVnaZkeFzdQyMZu1cgjg7k1pZZ6pvBQ7XJPt4swbTQ2",
"proofPurpose": "assertionMethod",
"proofValue": "z64e3a7hAtYQ3pqCdBsPLRpNqJd5YTzbMP7WrotbqY7HtANPq3ZSYoycsz3tHxzqJM5GVR5bUk7TpjoxgdUDXMQaR"
}
}
38 changes: 38 additions & 0 deletions TestVectors/employmentAuth.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"@context": [
"https://www.w3.org/ns/credentials/v2",
"https://w3id.org/citizenship/v4rc1"
],
"type": [
"VerifiableCredential",
"EmploymentAuthorizationDocumentCredential"
],
"issuer": {
"id": "did:key:zDnaegE6RR3atJtHKwTRTWHsJ3kNHqFwv7n9YjTgmU7TyfU76",
"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIW2NgUPr/HwADaAIhG61j/AAAAABJRU5ErkJggg=="
},
"credentialSubject": {
"type": [
"Person",
"EmployablePerson"
],
"givenName": "JOHN",
"additionalName": "JACOB",
"familyName": "SMITH",
"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIW2Ng+M/wHwAEAQH/7yMK/gAAAABJRU5ErkJggg==",
"gender": "Male",
"residentSince": "2015-01-01",
"birthCountry": "Bahamas",
"birthDate": "1999-07-17",
"employmentAuthorizationDocument": {
"type": "EmploymentAuthorizationDocument",
"identifier": "83627465",
"lprCategory": "C09",
"lprNumber": "999-999-999"
}
},
"name": "Employment Authorization Document",
"description": "Example Country Employment Authorization Document.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TallTed so this ends up being no change. Is this what you wanted?

Copy link
Member

@TallTed TallTed Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this ends up being no change. Is this what you wanted?

I don't understand how it ends up being no change. All the earlier comments on this PR have what I believe to be editorial changes, reducing strings of 4, 5, 6 nouns to 3, 2, 1 noun, to ease comprehension by non-native English speakers and by various software tools.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TallTed I don't understand what the previous "as above" comment meant. I can rerun the test vector computation only if I know what to set the inputs to be. I need you and @dlongley to agree. Otherwise please recompute the test vectors that correspond to your changes and I can approve.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with whatever @TallTed wants as a description here.

Copy link
Member

@TallTed TallTed Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Wind4Greg — The gist is "don't use a sequence of 3 or more nouns to identify something". Doing this makes comprehending and using the document more difficult for non-native English speakers (and even many native English speakers), as well as those using various accessibility tools. This is an example:

Suggested change
"description": "Example Country Employment Authorization Document.",
"description": "Example \"Employment Authorization Document\" for Country.",

I'll go make specific suggestions where I had earlier said "as above". I do all my work through GitHub's web interface, so I cannot compute the text vectors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll go with "description": "Example Employment Authorization Document" extra escape sequences are confusing to implementers.

"validFrom": "2019-12-03T00:00:00Z",
"validUntil": "2029-12-03T00:00:00Z"
}
74 changes: 74 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2304,6 +2304,80 @@ <h3>Representation: eddsa-rdfc-2022</h3>
<pre class="example nohighlight" title="Signed Credential"
data-include="TestVectors/eddsa-rdfc-2022/signedDataInt.json" data-include-format="text"></pre>
</section>
<section>
<h3>Enhanced Example for Representation: eddsa-rdfc-2022</h3>
<p>
Here we again go through the steps of creating a credential signed with
`eddsa-rdfc-2022`, but with a more complicated input document. The
representation of the public key and the representation of the private key
are shown below.
</p>
<pre class="example nohighlight" title="Private and Public keys for Signature">
{
publicKeyMultibase: "z6MkrJVnaZkeFzdQyMZu1cgjg7k1pZZ6pvBQ7XJPt4swbTQ2",
secretKeyMultibase: "z3u2en7t5LR2WtQH5PfFqMqwVHBeXouLzo6haApm8XHqvjxq"
}
</pre>

<p>
Signing begins with a credential without an attached proof, which is converted
to canonical form, and then hashed, as shown in the following three examples.
</p>

<pre class="example nohighlight" title="Employment Authorization Credential without Proof" data-include="TestVectors/employmentAuth.json"
data-include-format="text"></pre>

<pre class="example nohighlight" title="Canonical Employment Authorization Credential without Proof" data-include="TestVectors/eddsa-rdfc-2022/employ/canonDocDataInt.txt"
data-include-format="text"></pre>


<pre class="example nohighlight" title="Hash of Canonical Employment Authorization Credential without Proof (hex)"
data-include="TestVectors/eddsa-rdfc-2022/employ/docHashDataInt.txt" data-include-format="text"></pre>

<p>
The next step is to take the proof options document, convert it to canonical
form, and obtain its hash, as shown in the next three examples.
</p>

<pre class="example nohighlight" title="Proof Options Document"
data-include="TestVectors/eddsa-rdfc-2022/employ/proofConfigDataInt.json" data-include-format="text"></pre>

<pre class="example nohighlight" title="Canonical Proof Options Document"
data-include="TestVectors/eddsa-rdfc-2022/employ/proofCanonDataInt.txt" data-include-format="text"></pre>

<pre class="example nohighlight" title="Hash of Canonical Proof Options Document (hex)"
data-include="TestVectors/eddsa-rdfc-2022/employ/proofHashDataInt.txt" data-include-format="text"></pre>

<p>
Finally, we concatenate the hash of the proof options followed by the hash of
the credential without proof, use the private key with the combined hash to
compute the Ed25519 signature, and then base58-btc encode the signature.
</p>

<pre class="example nohighlight" title="Combine hashes of Proof Options and Credential (hex)"
data-include="TestVectors/eddsa-rdfc-2022/employ/combinedHashDataInt.txt" data-include-format="text"></pre>

<pre class="example nohighlight" title="Signature of Combined Hashes (hex)"
data-include="TestVectors/eddsa-rdfc-2022/employ/sigHexDataInt.txt" data-include-format="text"></pre>

<pre class="example nohighlight" title="Signature of Combined Hashes base58-btc"
data-include="TestVectors/eddsa-rdfc-2022/employ/sigBTC58DataInt.txt" data-include-format="text"></pre>

<p>Assemble the signed credential with the following two steps:</p>
<ol>
<li>
Add the <code>proofValue</code> field with the previously computed base58-btc
value to the proof options document.
</li>
<li>
Set the <code>proof</code> field of the credential to the augmented proof
option document.
</li>
</ol>

<pre class="example nohighlight" title="Signed Employment Authorization Credential"
data-include="TestVectors/eddsa-rdfc-2022/employ/signedDataInt.json" data-include-format="text"></pre>
</section>
<section>
<h3>Representation: eddsa-jcs-2022</h3>
<p>
Expand Down