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

How to use this with https://github.com/beatt83/peerdid-swift? #2

Open
jorge-riberi opened this issue Apr 3, 2024 · 1 comment

Comments

@jorge-riberi
Copy link

Hi, can you provide an example for use with peerdid-swift? Thanks!

@beatt83
Copy link
Owner

beatt83 commented Apr 8, 2024

Hi there. This would be it.

I really need to provide some better examples on the readme. But hope this can help for now, the peerDID library is straight forward then you just need to convert it to a DID. I took the examples from the tests in the peerdid-swift.

let ed25519_key1_jwk = PeerDIDVerificationMaterial(
    format: .jwk,
    \\ this is from peer DID tests
    value: JWK.testableData(),
    type: .authentication(.jsonWebKey2020)
)

let x25519_key_jwk = PeerDIDVerificationMaterial(
    format: .jwk,
    \\ this is from peer DID tests
    value: JWK.testableData(crv: "X25519", x: "BIiFcQEn3dfvB2pjlhOQQour6jXy9d5s2FKEJNTOJik"),
    type: .agreement(.jsonWebKey2020)
)

let peerDID = try PeerDIDHelper.createAlgo2(
    authenticationKeys: [ed25519_key1_jwk],
    agreementKeys: [x25519_key_jwk],
    services: [validService]
)

let yourDID = DID(string: peerDID.string)
let otherDID = DID(string: "did:peer:alice")

let didcomm = DIDComm(
    didResolver: // ... DID Resolver implementation,
    secretResolver: // ... Secret Resolver implementation
)

let basicMessage = Message(
           id: // UUID, 
           type: // protocol id string,
           from: yourDID,
           to: [otherDID]
)

let packed = try await didcomm.packSigned(params: .init(
    message: basicMessage,
    signFrom: "peerDID.string\(#key-0)" // Replace with actual signer DID Key ID
))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants