generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into msrv-1.70.0
* main: Use error for Verifier::verify(), Add ed25519 unit tests, Add Web5Error::Crypto (#300) Test Secp256k1Generator (#302) Generate X25519 keys (#301) Support X25519 in did:dht verification method (#299) add sign and verify test vectors (#292) Add feature complete Jwk (#294)
- Loading branch information
Showing
62 changed files
with
2,341 additions
and
416 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use crate::errors::Result; | ||
use web5::crypto::jwk::Jwk as InnerJwk; | ||
|
||
pub struct Jwk(pub InnerJwk); | ||
|
||
impl Jwk { | ||
pub fn new(data: InnerJwk) -> Self { | ||
Self(data) | ||
} | ||
|
||
pub fn get_data(&self) -> InnerJwk { | ||
self.0.clone() | ||
} | ||
|
||
pub fn compute_thumbprint(&self) -> Result<String> { | ||
let thumbprint = self.0.compute_thumbprint()?; | ||
Ok(thumbprint) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod dsa; | ||
|
||
pub mod in_memory_key_manager; | ||
pub mod jwk; | ||
pub mod key_manager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
use web5::dids::portable_did::PortableDid as InnerPortableDid; | ||
|
||
use crate::errors::Result; | ||
use web5::{ | ||
dids::portable_did::PortableDid as InnerPortableDid, | ||
json::{FromJson, ToJson}, | ||
}; | ||
|
||
pub struct PortableDid(pub InnerPortableDid); | ||
|
||
impl PortableDid { | ||
pub fn new(json: &str) -> Result<Self> { | ||
let inner_portable_did = InnerPortableDid::new(json)?; | ||
pub fn from_json_string(json: &str) -> Result<Self> { | ||
let inner_portable_did = InnerPortableDid::from_json_string(json)?; | ||
Ok(Self(inner_portable_did)) | ||
} | ||
|
||
pub fn get_data(&self) -> InnerPortableDid { | ||
self.0.clone() | ||
} | ||
|
||
pub fn to_json_string(&self) -> Result<String> { | ||
let json_string = self.0.to_json_string()?; | ||
Ok(json_string) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
bound/kt/src/main/kotlin/web5/sdk/crypto/Ed25519Generator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package web5.sdk.crypto | ||
|
||
import web5.sdk.crypto.keys.Jwk | ||
import web5.sdk.rust.ed25519GeneratorGenerate | ||
|
||
/** | ||
* Generates private key material for Ed25519. | ||
*/ | ||
class Ed25519Generator { | ||
companion object { | ||
/** | ||
* Generate the private key material; return Jwk includes private key material. | ||
* | ||
* @return Jwk the JWK with private key material included. | ||
*/ | ||
fun generate(): Jwk { | ||
val rustCoreJwkData = ed25519GeneratorGenerate() | ||
return Jwk.fromRustCoreJwkData(rustCoreJwkData) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,44 @@ | ||
package web5.sdk.crypto.keys | ||
|
||
import web5.sdk.rust.Jwk as RustCoreJwk | ||
import web5.sdk.rust.JwkData as RustCoreJwkData | ||
|
||
/** | ||
* Partial representation of a [JSON Web Key as per RFC7517](https://tools.ietf.org/html/rfc7517). | ||
* Note that this is a subset of the spec. | ||
*/ | ||
data class Jwk ( | ||
val alg: String? = null, | ||
val kty: String, | ||
val crv: String, | ||
val x: String, | ||
val y: String? = null, | ||
val d: String? = null | ||
) { | ||
internal val rustCoreJwkData: RustCoreJwkData = RustCoreJwkData( | ||
alg, | ||
kty, | ||
crv, | ||
d, | ||
x, | ||
y | ||
) | ||
|
||
typealias Jwk = RustCoreJwkData | ||
internal companion object { | ||
fun fromRustCoreJwkData(rustCoreJwkData: RustCoreJwkData): Jwk { | ||
return Jwk( | ||
rustCoreJwkData.alg, | ||
rustCoreJwkData.kty, | ||
rustCoreJwkData.crv, | ||
rustCoreJwkData.x, | ||
rustCoreJwkData.y, | ||
rustCoreJwkData.d, | ||
) | ||
} | ||
} | ||
|
||
fun computeThumbprint(): String { | ||
val rustCoreJwk = RustCoreJwk(rustCoreJwkData) | ||
return rustCoreJwk.computeThumbprint() | ||
} | ||
} |
Oops, something went wrong.