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

Fix EIP-712/Eip712Method2021 #106

Merged
merged 1 commit into from
Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ sha2 = { version = "0.9", optional = true }
hyper = { version = "0.14", optional = true, features = ["server", "client", "http1", "stream"] }
hyper-tls = { version = "0.5", optional = true }
http = { version = "0.2", optional = true }
hex = "0.4"
serde_urlencoded = "0.7"
percent-encoding = { version = "2.1", optional = true }
tokio = { version = "1.0", optional = true, features = ["macros"] }
Expand Down
12 changes: 10 additions & 2 deletions did-ethr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,8 @@ mod tests {
async fn credential_prove_verify_did_ethr() {
eprintln!("with EcdsaSecp256k1RecoveryMethod2020...");
credential_prove_verify_did_ethr2(false).await;
/*
eprintln!("with Eip712Method2021...");
credential_prove_verify_did_ethr2(true).await;
*/
}

async fn credential_prove_verify_did_ethr2(eip712: bool) {
Expand Down Expand Up @@ -326,4 +324,14 @@ mod tests {
vp2.holder = Some(URI::String("did:example:bad".to_string()));
assert!(vp2.verify(None, &DIDEthr).await.errors.len() > 0);
}

#[tokio::test]
async fn credential_verify_eip712vm() {
use ssi::vc::Credential;
let vc: Credential = serde_json::from_str(include_str!("../tests/vc.jsonld")).unwrap();
eprintln!("vc {:?}", vc);
let verification_result = vc.verify(None, &DIDEthr).await;
println!("{:#?}", verification_result);
assert!(verification_result.errors.is_empty());
}
}
79 changes: 79 additions & 0 deletions did-ethr/tests/vc.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
{
"sameAs": "https://www.w3.org/TR/owl-ref/#sameAs-def"
}
],
"id": "urn:uuid:dc093ee6-e039-40e7-8599-da2075666e2c",
"type": [
"VerifiableCredential"
],
"credentialSubject": {
"id": "did:example:foo",
"sameAs": "did:ethr:0xf7398bacf610bb4e3b567811279fcb3c41919f89"
},
"issuer": "did:ethr:0xf7398bacf610bb4e3b567811279fcb3c41919f89",
"issuanceDate": "2021-02-27T04:03:23.188Z",
"proof": {
"@context": [
{
"Eip712Method2021": "https://w3id.org/security#Eip712Method2021",
"Eip712Signature2021": {
"@context": {
"@protected": true,
"@version": 1.1,
"challenge": "https://w3id.org/security#challenge",
"created": {
"@id": "http://purl.org/dc/terms/created",
"@type": "http://www.w3.org/2001/XMLSchema#dateTime"
},
"domain": "https://w3id.org/security#domain",
"expires": {
"@id": "https://w3id.org/security#expiration",
"@type": "http://www.w3.org/2001/XMLSchema#dateTime"
},
"id": "@id",
"nonce": "https://w3id.org/security#nonce",
"proofPurpose": {
"@context": {
"@protected": true,
"@version": 1.1,
"assertionMethod": {
"@container": "@set",
"@id": "https://w3id.org/security#assertionMethod",
"@type": "@id"
},
"authentication": {
"@container": "@set",
"@id": "https://w3id.org/security#authenticationMethod",
"@type": "@id"
},
"id": "@id",
"type": "@type"
},
"@id": "https://w3id.org/security#proofPurpose",
"@type": "@vocab"
},
"proofValue": "https://w3id.org/security#proofValue",
"publicKeyJwk": {
"@id": "https://w3id.org/security#publicKeyJwk",
"@type": "@json"
},
"type": "@type",
"verificationMethod": {
"@id": "https://w3id.org/security#verificationMethod",
"@type": "@id"
}
},
"@id": "https://w3id.org/security#Eip712Signature2021"
}
}
],
"type": "Eip712Signature2021",
"proofPurpose": "assertionMethod",
"proofValue": "0x258e647f27ac39de2fe43b629b6189a20bfa1454bf76eb486f1461565c6c119c58b0676b2003c75ad51e88bbbca0a5ca944a2f292dc5f76f5d2db2be705a50ca1b",
"verificationMethod": "did:ethr:0xf7398bacf610bb4e3b567811279fcb3c41919f89#Eip712Method2021",
"created": "2021-02-27T04:03:23.189Z"
}
}
Loading