Skip to content

Commit

Permalink
Bring JwkDocumentExt names in line with Wasm (#1223)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippGackstatter authored Aug 28, 2023
1 parent 93437fc commit 6fb2df4
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 50 deletions.
6 changes: 3 additions & 3 deletions bindings/wasm/src/did/wasm_core_document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ impl WasmCoreDocument {
document_lock_clone
.read()
.await
.sign_bytes(&storage_clone, &fragment, payload.as_bytes(), &options_clone)
.create_jws(&storage_clone, &fragment, payload.as_bytes(), &options_clone)
.await
.wasm_result()
.map(WasmJws::new)
Expand Down Expand Up @@ -686,7 +686,7 @@ impl WasmCoreDocument {
document_lock_clone
.read()
.await
.sign_credential(&credential_clone, &storage_clone, &fragment, &options_clone)
.create_credential_jwt(&credential_clone, &storage_clone, &fragment, &options_clone)
.await
.wasm_result()
.map(WasmJwt::new)
Expand Down Expand Up @@ -718,7 +718,7 @@ impl WasmCoreDocument {
document_lock_clone
.read()
.await
.sign_presentation(
.create_presentation_jwt(
&presentation_clone,
&storage_clone,
&fragment,
Expand Down
6 changes: 3 additions & 3 deletions bindings/wasm/src/iota/iota_document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ impl WasmIotaDocument {
document_lock_clone
.read()
.await
.sign_bytes(&storage_clone, &fragment, payload.as_bytes(), &options_clone)
.create_jws(&storage_clone, &fragment, payload.as_bytes(), &options_clone)
.await
.wasm_result()
.map(WasmJws::new)
Expand Down Expand Up @@ -732,7 +732,7 @@ impl WasmIotaDocument {
document_lock_clone
.read()
.await
.sign_credential(&credential_clone, &storage_clone, &fragment, &options_clone)
.create_credential_jwt(&credential_clone, &storage_clone, &fragment, &options_clone)
.await
.wasm_result()
.map(WasmJwt::new)
Expand Down Expand Up @@ -764,7 +764,7 @@ impl WasmIotaDocument {
document_lock_clone
.read()
.await
.sign_presentation(
.create_presentation_jwt(
&presentation_clone,
&storage_clone,
&fragment,
Expand Down
2 changes: 1 addition & 1 deletion examples/0_basic/5_create_vc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async fn main() -> anyhow::Result<()> {
.build()?;

let credential_jwt: Jwt = issuer_document
.sign_credential(&credential, &issuer_storage, &fragment, &JwsSignatureOptions::default())
.create_credential_jwt(&credential, &issuer_storage, &fragment, &JwsSignatureOptions::default())
.await?;

// Before sending this credential to the holder the issuer wants to validate that some properties
Expand Down
4 changes: 2 additions & 2 deletions examples/0_basic/6_create_vp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ async fn main() -> anyhow::Result<()> {
.build()?;

let credential_jwt: Jwt = issuer_document
.sign_credential(
.create_credential_jwt(
&credential,
&storage_issuer,
&fragment_issuer,
Expand Down Expand Up @@ -160,7 +160,7 @@ async fn main() -> anyhow::Result<()> {
// Create a JWT verifiable presentation using the holder's verification method
// and include the requested challenge and expiry timestamp.
let presentation_jwt: Jwt = alice_document
.sign_presentation(
.create_presentation_jwt(
&presentation,
&storage_alice,
&fragment_alice,
Expand Down
2 changes: 1 addition & 1 deletion examples/0_basic/7_revoke_vc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ async fn main() -> anyhow::Result<()> {
println!("Credential JSON > {credential:#}");

let credential_jwt: Jwt = issuer_document
.sign_credential(
.create_credential_jwt(
&credential,
&storage_issuer,
&fragment_issuer,
Expand Down
2 changes: 1 addition & 1 deletion examples/0_basic/8_stronghold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ async fn main() -> anyhow::Result<()> {
// Sign data with the created verification method.
let data = b"test_data";
let jws: Jws = resolved_document
.sign_bytes(&storage, &fragment, data, &JwsSignatureOptions::default())
.create_jws(&storage, &fragment, data, &JwsSignatureOptions::default())
.await?;

// Verify Signature.
Expand Down
2 changes: 1 addition & 1 deletion examples/1_advanced/6_domain_linkage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ async fn main() -> anyhow::Result<()> {
.build()?;

let jwt: Jwt = updated_did_document
.sign_credential(
.create_credential_jwt(
&domain_linkage_credential,
&storage,
&fragment,
Expand Down
30 changes: 15 additions & 15 deletions identity_storage/src/storage/jwk_document_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ pub trait JwkDocumentExt: private::Sealed {
/// public key material in the verification method identified by the given `fragment.
///
/// Upon success a string representing a JWS encoded according to the Compact JWS Serialization format is returned.
/// See [RFC7515 section 3.1](https://www.rfc-editor.org/rfc/rfc7515#section-3.1).
async fn sign_bytes<K, I>(
/// See [RFC7515 section 3.1](https://www.rfc-editor.org/rfc/rfc7515#section-3.1).
async fn create_jws<K, I>(
&self,
storage: &Storage<K, I>,
fragment: &str,
Expand All @@ -99,7 +99,7 @@ pub trait JwkDocumentExt: private::Sealed {
///
/// The `kid` in the protected header is the `id` of the method identified by `fragment` and the JWS signature will be
/// produced by the corresponding private key backed by the `storage` in accordance with the passed `options`.
async fn sign_credential<K, I, T>(
async fn create_credential_jwt<K, I, T>(
&self,
credential: &Credential<T>,
storage: &Storage<K, I>,
Expand All @@ -116,7 +116,7 @@ pub trait JwkDocumentExt: private::Sealed {
///
/// The `kid` in the protected header is the `id` of the method identified by `fragment` and the JWS signature will be
/// produced by the corresponding private key backed by the `storage` in accordance with the passed `options`.
async fn sign_presentation<K, I, CRED, T>(
async fn create_presentation_jwt<K, I, CRED, T>(
&self,
presentation: &Presentation<CRED, T>,
storage: &Storage<K, I>,
Expand Down Expand Up @@ -327,7 +327,7 @@ impl JwkDocumentExt for CoreDocument {
purge_method_core_document(self, storage, id).await
}

async fn sign_bytes<K, I>(
async fn create_jws<K, I>(
&self,
storage: &Storage<K, I>,
fragment: &str,
Expand Down Expand Up @@ -414,7 +414,7 @@ impl JwkDocumentExt for CoreDocument {
Ok(Jws::new(jws_encoder.into_jws(&signature)))
}

async fn sign_credential<K, I, T>(
async fn create_credential_jwt<K, I, T>(
&self,
credential: &Credential<T>,
storage: &Storage<K, I>,
Expand All @@ -441,12 +441,12 @@ impl JwkDocumentExt for CoreDocument {

let payload = credential.serialize_jwt().map_err(Error::ClaimsSerializationError)?;
self
.sign_bytes(storage, fragment, payload.as_bytes(), options)
.create_jws(storage, fragment, payload.as_bytes(), options)
.await
.map(|jws| Jwt::new(jws.into()))
}

async fn sign_presentation<K, I, CRED, T>(
async fn create_presentation_jwt<K, I, CRED, T>(
&self,
presentation: &Presentation<CRED, T>,
storage: &Storage<K, I>,
Expand Down Expand Up @@ -476,7 +476,7 @@ impl JwkDocumentExt for CoreDocument {
.serialize_jwt(jwt_options)
.map_err(Error::ClaimsSerializationError)?;
self
.sign_bytes(storage, fragment, payload.as_bytes(), jws_options)
.create_jws(storage, fragment, payload.as_bytes(), jws_options)
.await
.map(|jws| Jwt::new(jws.into()))
}
Expand Down Expand Up @@ -540,7 +540,7 @@ mod iota_document {
purge_method_iota_document(self, storage, id).await
}

async fn sign_bytes<K, I>(
async fn create_jws<K, I>(
&self,
storage: &Storage<K, I>,
fragment: &str,
Expand All @@ -553,11 +553,11 @@ mod iota_document {
{
self
.core_document()
.sign_bytes(storage, fragment, payload, options)
.create_jws(storage, fragment, payload, options)
.await
}

async fn sign_credential<K, I, T>(
async fn create_credential_jwt<K, I, T>(
&self,
credential: &Credential<T>,
storage: &Storage<K, I>,
Expand All @@ -571,10 +571,10 @@ mod iota_document {
{
self
.core_document()
.sign_credential(credential, storage, fragment, options)
.create_credential_jwt(credential, storage, fragment, options)
.await
}
async fn sign_presentation<K, I, CRED, T>(
async fn create_presentation_jwt<K, I, CRED, T>(
&self,
presentation: &Presentation<CRED, T>,
storage: &Storage<K, I>,
Expand All @@ -590,7 +590,7 @@ mod iota_document {
{
self
.core_document()
.sign_presentation(presentation, storage, fragment, options, jwt_options)
.create_presentation_jwt(presentation, storage, fragment, options, jwt_options)
.await
}
}
Expand Down
14 changes: 7 additions & 7 deletions identity_storage/src/storage/tests/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ async fn sign_bytes() {
let verification_options: JwsVerificationOptions = JwsVerificationOptions::new();

let jws: Jws = document
.sign_bytes(&storage, &fragment, payload, &signature_options)
.create_jws(&storage, &fragment, payload, &signature_options)
.await
.unwrap();

Expand All @@ -133,7 +133,7 @@ async fn sign_bytes_with_nonce() {
let verification_options: JwsVerificationOptions = JwsVerificationOptions::new().nonce(nonce);

let jws: Jws = document
.sign_bytes(&storage, &fragment, payload, &signature_options)
.create_jws(&storage, &fragment, payload, &signature_options)
.await
.unwrap();

Expand Down Expand Up @@ -178,7 +178,7 @@ async fn sign_bytes_with_header_copy_options() {
let verification_options: JwsVerificationOptions = JwsVerificationOptions::new();

let jws: Jws = document
.sign_bytes(&storage, &fragment, payload, &signature_options)
.create_jws(&storage, &fragment, payload, &signature_options)
.await
.unwrap();

Expand Down Expand Up @@ -212,7 +212,7 @@ async fn sign_bytes_detached() {
let verification_options: JwsVerificationOptions = JwsVerificationOptions::new();

let jws: Jws = document
.sign_bytes(&storage, fragment.as_ref(), payload, &signature_options)
.create_jws(&storage, fragment.as_ref(), payload, &signature_options)
.await
.unwrap();

Expand All @@ -232,7 +232,7 @@ async fn sign_bytes_detached() {
let signature_options: JwsSignatureOptions = JwsSignatureOptions::new().b64(true).detached_payload(true);

let jws: Jws = document
.sign_bytes(&storage, fragment.as_ref(), payload, &signature_options)
.create_jws(&storage, fragment.as_ref(), payload, &signature_options)
.await
.unwrap();
let payload_b64: String = encode_b64(payload);
Expand Down Expand Up @@ -284,7 +284,7 @@ async fn signing_credential() {

let credential: Credential = Credential::from_json(credential_json).unwrap();
let jws = document
.sign_credential(&credential, &storage, &method_fragment, &JwsSignatureOptions::default())
.create_credential_jwt(&credential, &storage, &method_fragment, &JwsSignatureOptions::default())
.await
.unwrap();
// Verify the credential
Expand Down Expand Up @@ -366,7 +366,7 @@ mod iota_document_tests {

// Sign the test string
let jws = iota_document
.sign_bytes(&storage, fragment, b"test", &JwsSignatureOptions::new())
.create_jws(&storage, fragment, b"test", &JwsSignatureOptions::new())
.await
.unwrap();

Expand Down
8 changes: 4 additions & 4 deletions identity_storage/src/storage/tests/credential_jws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async fn signing_credential_with_detached_option_fails() {
let (document, storage, kid, credential) = setup().await;

assert!(document
.sign_credential(
.create_credential_jwt(
&credential,
&storage,
kid.as_ref(),
Expand All @@ -94,7 +94,7 @@ async fn signing_credential_with_nonce_and_scope() {
let nonce: &str = "0xaabbccddeeff";

let jws = document
.sign_credential(
.create_credential_jwt(
&credential,
&storage,
kid.as_ref(),
Expand Down Expand Up @@ -151,7 +151,7 @@ async fn signing_credential_with_b64() {
let (document, storage, kid, credential) = setup().await;

let jws = document
.sign_credential(
.create_credential_jwt(
&credential,
&storage,
kid.as_ref(),
Expand All @@ -177,7 +177,7 @@ async fn signing_credential_with_b64() {

// JWTs should not have `b64` set per https://datatracker.ietf.org/doc/html/rfc7797#section-7.
assert!(document
.sign_credential(
.create_credential_jwt(
&credential,
&storage,
kid.as_ref(),
Expand Down
10 changes: 5 additions & 5 deletions identity_storage/src/storage/tests/credential_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ where
} = test_utils::generate_credential(&issuer_doc, &[&subject_doc], None, None);

let jws = issuer_doc
.sign_credential(
.create_credential_jwt(
&credential,
&storage,
method_fragment.as_ref(),
Expand Down Expand Up @@ -128,7 +128,7 @@ where
} = test_utils::generate_credential(&issuer_doc, &[&subject_doc], None, None);

let jwt: Jwt = issuer_doc
.sign_credential(
.create_credential_jwt(
&credential,
&storage,
method_fragment.as_ref(),
Expand Down Expand Up @@ -169,7 +169,7 @@ where
let CredentialSetup { credential, .. } = test_utils::generate_credential(&issuer_doc, &[&subject_doc], None, None);

let jwt: Jwt = issuer_doc
.sign_credential(
.create_credential_jwt(
&credential,
&storage,
method_fragment.as_ref(),
Expand Down Expand Up @@ -233,7 +233,7 @@ where

// Sign the credential with the *other* issuer.
let jwt: Jwt = other_issuer_doc
.sign_credential(&credential, &other_storage, fragment, &JwsSignatureOptions::default())
.create_credential_jwt(&credential, &other_storage, fragment, &JwsSignatureOptions::default())
.await
.unwrap();

Expand Down Expand Up @@ -392,7 +392,7 @@ where
} = test_utils::generate_credential(&issuer_doc, &[&subject_doc], None, None);

let jws = issuer_doc
.sign_credential(
.create_credential_jwt(
&credential,
&storage,
method_fragment.as_ref(),
Expand Down
Loading

0 comments on commit 6fb2df4

Please sign in to comment.