Skip to content

Commit

Permalink
doc: Update ARC52 API and description
Browse files Browse the repository at this point in the history
Signed-off-by: ehanoc <[email protected]>
  • Loading branch information
ehanoc committed Oct 25, 2023
1 parent 5874b3f commit 2488fa5
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions ARCs/arc-0052.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ This extension is **OPTIONAL** and separate from the current interface that hand

interface Wallet {
...
keyGen(context: KeyContext, name: string): Promise<Uint8Array>;
sign(context: KeyContext, name: string, message: Uint8Array): Promise<Uint8Array>;
keyGen(context: KeyContext, account:number, keyIndex: number): Promise<Uint8Array>;
signData(context: KeyContext, account:number, keyIndex: number, message: Uint8Array): Promise<Uint8Array>;
...
}
```
Expand All @@ -91,17 +91,15 @@ In order to derive a key, the wallet should lookup the different derivation path
- **method name**: `keyGen`
- **parameters**:
- `context`: The context of the key to be generated
- `type` (optional): The type of key to be generated. Possible values are `p-256`, `ed25519`
- Default value: `ed25519`
- `options`(optional):
- `index`: The index of the key to be generated. If not provided, the wallet should derive the next key in the derivation path.
- `key-identifier`(optional): Optional parameter to give the key a rememberable name (i.e "my-did"). Note: this wouldn't be recoverable from the mnemonic.
- `account`: The account index to be used for key derivation. The value value should be hardened as per BIP44
- `keyIndex`: The key index to be used for key derivation.

- **returns**: Byte array cointaing the public key, which is a point on the Ed25519 elliptic curve. The public key is encoded as compressed EC point: the y-coordinate, combined with the lowest bit (the parity) of the x-coordinate, making up 32 bytes.

###### Example

```ts
const identityKey: Uint8Array = await wallet.keyGen(KeyContext.Identity, "ed25519", { index: 0, key-identifier: "myGamingId" })
const identityKey: Uint8Array = await wallet.keyGen(KeyContext.Identity, 0, 0)

```
##### sign
Expand All @@ -115,26 +113,15 @@ Signing operation that can be used to perform arbitrary signing operations in a
- **parameters**:
- `data`: The data to be signed
- `context`: The context of the key to be used for signing
- `account`: The account index to be used for key derivation. The value value should be hardened as per BIP44
- `keyIndex`: The key index to be used for key derivation.
- `metadata`: Object to describe the type of data that is being signed. It should specify the encoding used (i.e msgpack, cbor, etc) and a schema so that the wallet can decode it to show the user.
- `encoding`: The encoding used for the data
- `schema`: The schema of the data in the form of a JSON schema
- `type`(optional): The key type to be used for signing. Possible values are `ecdsa-p256`, `ed25519`
- Default value: `ed25519`
- **returns**: Byte array containing the signature. The signature is encoded as a 64-byte array (32 + 32 bytes). It holds a compressed point R + the integer s (confirming that the signer knows the msg and the privKey).
- Throws error if data doesn't match the schema

###### Example

```ts
// Example -> sign auth challenge request with an Address Key

const authChallenge: Uint8Array = await wallet.sign("my-auth-challenge", KeyContext.Address, { encoding: "cbor", schema: { type: "object", properties: { challenge: { type: "string" } } } }, "ed25519", { index: 0 })

```


## Security Considerations

TBC

## Copyright
Copyright and related rights waived via <a href="https://creativecommons.org/publicdomain/zero/1.0/">CCO</a>.

0 comments on commit 2488fa5

Please sign in to comment.