Skip to content

Commit

Permalink
Reply to a few review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Olshansk committed Feb 13, 2024
1 parent dc232f1 commit 4f13ce1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
22 changes: 10 additions & 12 deletions doc/specs/application-auth-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ description: >-
- [applicationPublicKey](#applicationpublickey)
- [clientPublicKey](#clientpublickey)
- [ECDSA ed25519 Signature Scheme](#ecdsa-ed25519-signature-scheme)
- [AAT Uses-Cases](#aat-uses-cases)
- [AAT Generation](#aat-generation)
- [1. Application === Client (Gateway)](#1-application--client-gateway)
- [2. Application !== Gateway (Client)](#2-application--gateway-client)
- [AAT Generation](#aat-generation)
- [Relay Generation](#relay-generation)
- [AAT Signature Generation](#aat-signature-generation)
- [Relay Generation \& Signing using AAT](#relay-generation--signing-using-aat)

## Data Structure Schema

Expand All @@ -35,8 +35,9 @@ A semver string specifying the spec version under which this AAT needs to be int

> type: `string`
The application will sign a hash of the `message` property within this token with
the specified `appPubKey` and corresponding private key.
The `Application` will sign a hash of a marshalled AAT structure where all the fields
are populated with the exception of the `Signature` itself. The resultant `Signature`
is the one that's populated in the `AAT`.

### applicationPublicKey

Expand All @@ -59,7 +60,7 @@ The hexadecimal public key allowing granular control of who can use the `AAT`.
The protocol wide ed25519 ECDSA will be used for any signatures and verifications
that are used within this specification.

## AAT Uses-Cases
## AAT Generation

When generating a new AAT, the owner of the `Application` private key has two options:

Expand Down Expand Up @@ -107,7 +108,7 @@ flowchart TB
end
```

### AAT Generation
### AAT Signature Generation

The proper way to sign the token is as follows:

Expand All @@ -128,7 +129,7 @@ The proper way to sign the token is as follows:
AAT.ApplicationSignature = ED25519.Sign(Message)
```

### Relay Generation
### Relay Generation & Signing using AAT

The `Client` is needed to sign the actual relays while the `Application` gets
charged on-chain. However, the `Application` only gets charged if the `Client`
Expand All @@ -138,9 +139,9 @@ by the `Application` during `AAT` generation.
```mermaid
flowchart TB
RP([Relay Proof])
CG([ClientPrivateKey/ \n GatePrivateKey])
subgraph RPU["Unsigned RelayProof"]
direction TB
requestHash
Entropy
SessionHeight
Expand All @@ -149,9 +150,6 @@ flowchart TB
BlockchainID
end
AAT <-.-> CG
CG <-.-> sig
RPU -- hash --> RPUB["RelayProof Bytes"]
RPUB -- "Sign with Client/Gateway\nPrivate Key" --> sig["Client/Gateway Signature"]
Expand Down
5 changes: 2 additions & 3 deletions x/pocketcore/keeper/aat.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ func AATGeneration(appPubKey, clientPubKey string, appPrivKey crypto.PrivateKey)
// marshal the AAT structure
aatBytes := aat.Hash()

// sign the AAT
// This is where the `ApplicationPrivKey` signs (i.e. delegates trust) to
// the underlying`ClientPublicKey`.
sig, err := appPrivKey.Sign(aatBytes)
if err != nil {
return pc.AAT{}, pc.NewSignatureError(pc.ModuleName, err)
}

// This is where the `ApplicationPrivKey` signs (i.e. delegates trust) to
// the underlying`ClientPublicKey`.
aat.ApplicationSignature = hex.EncodeToString(sig)
return aat, nil
}

0 comments on commit 4f13ce1

Please sign in to comment.