diff options
| -rw-r--r-- | lib/paseto/peer.go | 4 | ||||
| -rw-r--r-- | lib/paseto/v2/example_public_mode_test.go | 12 | ||||
| -rw-r--r-- | lib/paseto/v2/public_mode.go | 8 | ||||
| -rw-r--r-- | lib/paseto/v2/public_mode_test.go | 6 | ||||
| -rw-r--r-- | lib/paseto/v4/public_mode.go | 14 |
5 files changed, 22 insertions, 22 deletions
diff --git a/lib/paseto/peer.go b/lib/paseto/peer.go index 8c077bb7..55d3bdb0 100644 --- a/lib/paseto/peer.go +++ b/lib/paseto/peer.go @@ -18,8 +18,8 @@ type Peer struct { ID string // PrivateKey for signing message. - Private ed25519.PrivateKey + PrivateKey ed25519.PrivateKey // PublicKey for verifying message. - Public ed25519.PublicKey + PublicKey ed25519.PublicKey } diff --git a/lib/paseto/v2/example_public_mode_test.go b/lib/paseto/v2/example_public_mode_test.go index 967321f9..17375752 100644 --- a/lib/paseto/v2/example_public_mode_test.go +++ b/lib/paseto/v2/example_public_mode_test.go @@ -18,9 +18,9 @@ func ExamplePublicMode() { senderSK, _ := hex.DecodeString("e9ae9c7eae2fce6fd6727b5ca8df0fbc0aa60a5ffb354d4fdee1729e4e1463688d2160a4dc71a9a697d6ad6424da3f9dd18a259cdd51b0ae2b521e998b82d36e") senderPK, _ := hex.DecodeString("8d2160a4dc71a9a697d6ad6424da3f9dd18a259cdd51b0ae2b521e998b82d36e") senderKey := paseto.Peer{ - ID: "sender", - Private: ed25519.PrivateKey(senderSK), - Public: ed25519.PublicKey(senderPK), + ID: `sender`, + PrivateKey: ed25519.PrivateKey(senderSK), + PublicKey: ed25519.PublicKey(senderPK), AllowedSubjects: map[string]struct{}{ subjectMessage: struct{}{}, }, @@ -29,9 +29,9 @@ func ExamplePublicMode() { receiverSK, _ := hex.DecodeString("4983da648bff1fd3e1892df9c56370215aa640829a5cab02d6616b115fa0bc5707c22e74ab9b181f8d87bdf03cf88476ec4c35e5517e173f236592f6695d59f5") receiverPK, _ := hex.DecodeString("07c22e74ab9b181f8d87bdf03cf88476ec4c35e5517e173f236592f6695d59f5") receiverKey := paseto.Peer{ - ID: "receiver", - Private: ed25519.PrivateKey(receiverSK), - Public: ed25519.PublicKey(receiverPK), + ID: `receiver`, + PrivateKey: ed25519.PrivateKey(receiverSK), + PublicKey: ed25519.PublicKey(receiverPK), } // diff --git a/lib/paseto/v2/public_mode.go b/lib/paseto/v2/public_mode.go index c10a7a42..b4714e43 100644 --- a/lib/paseto/v2/public_mode.go +++ b/lib/paseto/v2/public_mode.go @@ -37,7 +37,7 @@ func NewPublicMode(our paseto.Peer) (auth *PublicMode, err error) { if len(our.ID) == 0 { return nil, errors.New(`empty key ID`) } - if len(our.Private) == 0 { + if len(our.PrivateKey) == 0 { return nil, errors.New(`empty private key`) } auth = &PublicMode{ @@ -85,7 +85,7 @@ func (auth *PublicMode) AddPeer(k paseto.Peer) (err error) { if len(k.ID) == 0 { return errors.New(`empty key ID`) } - if len(k.Public) == 0 { + if len(k.PublicKey) == 0 { return errors.New(`empty public key`) } auth.peers.upsert(k) @@ -133,7 +133,7 @@ func (auth *PublicMode) Pack(audience, subject string, data []byte, footer map[s return "", err } - return Sign(auth.our.Private, msg, rawfooter) + return Sign(auth.our.PrivateKey, msg, rawfooter) } // Unpack the token to get the Payload and the data. @@ -171,7 +171,7 @@ func (auth *PublicMode) Unpack(token string) (msg *paseto.Message, err error) { return nil, err } - payload, err := Verify(peerKey.Public, msgSig, rawfooter) + payload, err := Verify(peerKey.PublicKey, msgSig, rawfooter) if err != nil { return nil, err } diff --git a/lib/paseto/v2/public_mode_test.go b/lib/paseto/v2/public_mode_test.go index 6375ba1c..e8da13e6 100644 --- a/lib/paseto/v2/public_mode_test.go +++ b/lib/paseto/v2/public_mode_test.go @@ -19,9 +19,9 @@ func TestPublicMode_UnpackHTTPRequest(t *testing.T) { senderSK, _ := hex.DecodeString("e9ae9c7eae2fce6fd6727b5ca8df0fbc0aa60a5ffb354d4fdee1729e4e1463688d2160a4dc71a9a697d6ad6424da3f9dd18a259cdd51b0ae2b521e998b82d36e") senderPK, _ := hex.DecodeString("8d2160a4dc71a9a697d6ad6424da3f9dd18a259cdd51b0ae2b521e998b82d36e") ourKey := paseto.Peer{ - ID: "sender", - Private: ed25519.PrivateKey(senderSK), - Public: ed25519.PublicKey(senderPK), + ID: "sender", + PrivateKey: ed25519.PrivateKey(senderSK), + PublicKey: ed25519.PublicKey(senderPK), AllowedSubjects: map[string]struct{}{ subjectMessage: struct{}{}, }, diff --git a/lib/paseto/v4/public_mode.go b/lib/paseto/v4/public_mode.go index 551f1a5e..7137b888 100644 --- a/lib/paseto/v4/public_mode.go +++ b/lib/paseto/v4/public_mode.go @@ -46,11 +46,11 @@ func NewPublicMode(id string, seed [ed25519.SeedSize]byte) (pmode *PublicMode) { pmode = &PublicMode{ peers: make(map[string]paseto.Peer), Peer: paseto.Peer{ - ID: id, - Private: ed25519.NewKeyFromSeed(seed[:]), + ID: id, + PrivateKey: ed25519.NewKeyFromSeed(seed[:]), }, } - pmode.Public = pmode.Private.Public().(ed25519.PublicKey) + pmode.PublicKey = pmode.PrivateKey.Public().(ed25519.PublicKey) return pmode } @@ -62,7 +62,7 @@ func (pmode *PublicMode) AddPeer(peer paseto.Peer) (err error) { if len(peer.ID) == 0 { return fmt.Errorf(`%s: %w`, logp, ErrPeerID) } - if len(peer.Public) == 0 { + if len(peer.PublicKey) == 0 { return fmt.Errorf(`%s: %w`, logp, ErrPeerID) } pmode.Lock() @@ -127,7 +127,7 @@ func (pmode *PublicMode) Sign(payload, footer, implicit []byte) ( } // Step 4: Sign pae. - sig := ed25519.Sign(pmode.Peer.Private, pae) + sig := ed25519.Sign(pmode.Peer.PrivateKey, pae) // Step 5: Pack all into token, var buf bytes.Buffer @@ -175,7 +175,7 @@ func (pmode *PublicMode) Unpack(token string, implicit []byte, msg *paseto.Messa return fmt.Errorf(`%s: %w %s`, logp, ErrPeerID, msg.Footer.PeerID) } - if !ed25519.Verify(sender.Public, msg.PAE, msg.Sig) { + if !ed25519.Verify(sender.PublicKey, msg.PAE, msg.Sig) { return fmt.Errorf(`%s: %w`, logp, ErrSignature) } @@ -202,7 +202,7 @@ func (pmode *PublicMode) Verify(token string, implicit []byte) ( } // Step 6: Verify the signature. - if !ed25519.Verify(pmode.Peer.Public, msg.PAE, msg.Sig) { + if !ed25519.Verify(pmode.Peer.PublicKey, msg.PAE, msg.Sig) { return nil, nil, fmt.Errorf(`%s: %w`, logp, ErrSignature) } |
