Skip to content

Commit e59b465

Browse files
authored
init: secp256k1 support (#343)
# Problem Changes to support Secp256k1 signatures. # Future work - Docs still needs to be fixed and updated but the library is good to go
1 parent ad7d337 commit e59b465

49 files changed

Lines changed: 9145 additions & 13357 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/verify-pr-v2-tool-generator.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
node-version: [22.x]
1616
runs-on: ubuntu-latest
1717
container:
18-
image: mcr.microsoft.com/playwright:v1.53.0-noble
18+
image: mcr.microsoft.com/playwright:v1.53.1-noble
1919

2020
steps:
2121
- name: Checkout

.github/workflows/verify-pr-v2-web-sdk.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
node-version: [20.x, 22.x]
1616
runs-on: ubuntu-latest
1717
container:
18-
image: mcr.microsoft.com/playwright:v1.53.0-noble
18+
image: mcr.microsoft.com/playwright:v1.53.1-noble
1919

2020
steps:
2121
- name: Checkout

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,7 @@ package/
5656
vite.config.js.timestamp-*
5757
vite.config.ts.timestamp-*
5858

59-
.idea
59+
.idea
60+
*.iml
61+
*.ipr
62+
*.iws

docs/src/Actions/Response.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ These credentials follow the [DSNP Verifiable Credentials Specification](https:/
4949
_Trust Model Note_: You may choose to just trust credentials issued by Frequency Access (or other SIWF-compatible services) given that the credential is fetched directly. These will have issuer `did:web:testnet.frequencyaccess.com` or `did:web:frequencyaccess.com`.
5050

5151
1. Check that the `credentialSubject.id` matches the `userPublicKey` following the [`did:key` Method from the W3C](https://w3c-ccg.github.io/did-key-spec/#format)
52-
- Example: `f6cL4wq1HUNx11TcvdABNf9UNXXoyH47mVUwT59tzSFRW8yDH` is the [SS58](https://docs.substrate.io/reference/address-formats/) version with prefix `90` of the hex address `0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d`. `0xef01d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d` is multicodec `sr25519-pub` hex which is multiformat `base58-btc` `z6QNzHod3tSSJbwo4e5xGDcnsndsR9WByZzPoCGdbv3sv1jJ`
53-
2. Fetch the issuer DID Document following the [`did:web` Method from the W3C](https://w3c-ccg.github.io/did-method-web/)
52+
- Sr25519 key Example: `f6cL4wq1HUNx11TcvdABNf9UNXXoyH47mVUwT59tzSFRW8yDH` is the [SS58](https://docs.substrate.io/reference/address-formats/) version with prefix `90` of the hex address `0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d`. `0xef01d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d` is multicodec `sr25519-pub` hex which is multiformat `base58-btc` `z6QNzHod3tSSJbwo4e5xGDcnsndsR9WByZzPoCGdbv3sv1jJ`
53+
- Secp256k1 ket example: `f6bgm3jyDVNxMf9zdYgHZmAQ8DqLVFDzvHQQc2BBpa5SK2bDw` is the [SS58](https://docs.substrate.io/reference/address-formats/) version with prefix `90` of the hex address `0xb7c13f4176ca799975d9cce4bafe4814a9d824faeeeeeeeeeeeeeeeeeeeeeeee`. `0xe701b7c13f4176ca799975d9cce4bafe4814a9d824faeeeeeeeeeeeeeeeeeeeeeeee` is multicodec `secp256k1-pub` (this will not work since we only have the 32 byte account id not the 33 byte public key) (?)
54+
3. Fetch the issuer DID Document following the [`did:web` Method from the W3C](https://w3c-ccg.github.io/did-method-web/)
5455
- Production-Mainnet should always be `did:web:frequencyaccess.com` which resolves to `https://frequencyaccess.com/.well-known/did.json`
5556
- Staging-Testnet should always be `did:web:testnet.frequencyaccess.com` which resolves to `https://testnet.frequencyaccess.com/.well-known/did.json`
5657
3. Check that the key in the `proof.verificationMethod` is in the DID Document to verify that the key is still valid
@@ -112,7 +113,7 @@ Inside the message, `{{domain}}` is the domain of the application requesting the
112113

113114
#### Validation Steps
114115

115-
1. Perform an Sr25519 signature verification using:
116+
1. Perform an Sr25519/Secp256k1 signature verification using:
116117
- `userPublicKey`: The signing key
117118
- `payload.message`: The signed message parsing `\n` into `LF` line breaks
118119
- `signature.encodedValue`: The signature
@@ -175,12 +176,24 @@ SIWF services do not manage user sessions.
175176

176177
## New Frequency User Response
177178

178-
{{#include ../DataStructures/Response-NewUser.md 0}}
179+
### Sr25519
180+
{{#include ../DataStructures/Sr25519/Response-NewUser.md 0}}
181+
182+
### Secp256k1
183+
{{#include ../DataStructures/Secp256k1/Response-NewUser.md 0}}
179184

180185
## New Application/Delegation Response
181186

182-
{{#include ../DataStructures/Response-NewProvider.md 0}}
187+
### Sr25519
188+
{{#include ../DataStructures/Sr25519/Response-NewProvider.md 0}}
189+
190+
### Secp256k1
191+
{{#include ../DataStructures/Secp256k1/Response-NewProvider.md 0}}
183192

184193
## Login Only Response
185194

186-
{{#include ../DataStructures/Response-LoginOnly.md 0}}
195+
### Sr25519
196+
{{#include ../DataStructures/Sr25519/Response-LoginOnly.md 0}}
197+
198+
### Secp256k1
199+
{{#include ../DataStructures/Secp256k1/Response-LoginOnly.md 0}}

docs/src/Actions/Start.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,23 @@ For example, if you wish to correlate the original unauthorized session with the
7474

7575
### Example
7676

77+
#### Sr25519
7778
Parameters
7879

79-
{{#include ../DataStructures/Request.md 0}}
80+
{{#include ../DataStructures/Sr25519/Request.md 0}}
8081

8182
Testnet Authentication URL
8283

83-
{{#include ../DataStructures/RequestUrl.md 0}}
84+
{{#include ../DataStructures/Sr25519/RequestUrl.md 0}}
85+
86+
#### Secp256k1
87+
Parameters
88+
89+
{{#include ../DataStructures/Secp256k1/Request.md 0}}
90+
91+
Testnet Authentication URL
92+
93+
{{#include ../DataStructures/Secp256k1/RequestUrl.md 0}}
8494

8595
## Step 4: Redirect the User
8696

docs/src/DataStructures/All.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,53 @@
44

55
### Request
66

7-
{{#include Request.md 0}}
7+
#### Sr25519
8+
{{#include ./Sr25519/Request.md 0}}
9+
10+
#### Secp256k1
11+
{{#include ./Secp256k1/Request.md 0}}
812

913
### Request URL
1014

11-
{{#include RequestUrl.md 0}}
15+
#### Sr25519
16+
{{#include ./Sr25519/RequestUrl.md 0}}
17+
18+
#### Secp256k1
19+
{{#include ./Secp256k1/RequestUrl.md 0}}
1220

1321
### Signed Request
1422

1523
This is JSON stringified and then [`base64url`](https://datatracker.ietf.org/doc/html/rfc4648#section-5) encoded for the Request `signedRequest` value.
1624

17-
{{#include SignedRequest.md 0}}
25+
#### Sr25519
26+
{{#include ./Sr25519/SignedRequest.md 0}}
27+
28+
#### Secp256k1
29+
{{#include ./Secp256k1/SignedRequest.md 0}}
1830

1931
### New Frequency User Response
2032

21-
{{#include Response-NewUser.md 0}}
33+
#### Sr25519
34+
{{#include ./Sr25519/Response-NewUser.md 0}}
35+
36+
#### Secp256k1
37+
{{#include ./Secp256k1/Response-NewUser.md 0}}
2238

2339
### New Application/Delegation Response
2440

25-
{{#include Response-NewProvider.md}}
41+
#### Sr25519
42+
{{#include ./Sr25519/Response-NewProvider.md 0}}
43+
44+
#### Secp256k1
45+
{{#include ./Secp256k1/Response-NewProvider.md 0}}
2646

2747
### Login Only Response
2848

29-
{{#include Response-LoginOnly.md}}
49+
#### Sr25519
50+
{{#include ./Sr25519/Response-LoginOnly.md 0}}
51+
52+
#### Secp256k1
53+
{{#include ./Secp256k1/Response-LoginOnly.md 0}}
3054

3155
## Verified User Data
3256

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
```json
2+
{
3+
"signedRequest": "eyJyZXF1ZXN0ZWRTaWduYXR1cmVzIjp7InB1YmxpY0tleSI6eyJlbmNvZGVkVm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OlsiYmNpcWpzcG5id3BjM3dqeDRmZXdjZWs1ZGF5c2RqcGJmNXhqaW16NXdudTV1ajdlM3Z1MnV3bnEiXX1dfV19&mode=dark"
3+
```
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
```json
2+
{
3+
"userPublicKey": {
4+
"encodedValue": "0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac",
5+
"encoding": "base16",
6+
"format": "eip-55",
7+
"type": "Secp256k1"
8+
},
9+
"payloads": [
10+
{
11+
"signature": {
12+
"algo": "SECP256K1",
13+
"encoding": "base16",
14+
"encodedValue": "0xe8a1f5ef2c4afc8296adf84f92971bf270d68e89ffc512d13d6f5b99c3b2cd9108d5868e8a3a46d1c406137947d73a054888e195390a1fc4f69c4b16df4119d41b"
15+
},
16+
"type": "login",
17+
"payload": {
18+
"message": "your-app.com wants you to sign in with your Frequency account:\n0xf24ff3a9cf04c71dbc94d0b566f7a27b94566cac\n\n\n\nURI: https://your-app.com/signin/callback\nNonce: N6rLwqyz34oUxJEXJ\nIssued At: 2024-10-29T19:17:27.077Z\nExpiration Time: 2060-03-05T23:23:03.041Z"
19+
}
20+
}
21+
],
22+
"credentials": []
23+
}
24+
```
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
```json
2+
{
3+
"userPublicKey": {
4+
"encodedValue": "0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac",
5+
"encoding": "base16",
6+
"format": "eip-55",
7+
"type": "Secp256k1"
8+
},
9+
"payloads": [
10+
{
11+
"signature": {
12+
"algo": "SECP256K1",
13+
"encoding": "base16",
14+
"encodedValue": "0xb3e41e53373649d089455965791c47f695f519eb21bd322febf04bd05f2b50b72c395c4490ac6cd0d108d0a77f625aea8b1f0096befc359936669d620f5aad7e1c"
15+
},
16+
"endpoint": {
17+
"pallet": "msa",
18+
"extrinsic": "grantDelegation"
19+
},
20+
"type": "addProvider",
21+
"payload": {
22+
"authorizedMsaId": 1,
23+
"schemaIds": [
24+
5,
25+
7,
26+
8,
27+
9,
28+
10
29+
],
30+
"expiration": 24
31+
}
32+
}
33+
],
34+
"credentials": []
35+
}
36+
```

0 commit comments

Comments
 (0)