diff options
| author | Shulhan <ms@kilabit.info> | 2026-03-30 19:38:32 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2026-03-30 21:07:31 +0700 |
| commit | 7af6aa612bc60df120d7580c9e436b24d2326394 (patch) | |
| tree | 3dcff3ecc05c43c33653c511aff7925a1258965b /lib/paseto/v4/public_mode.go | |
| parent | 61a44bf239f5545080af83f890d488ceaf257a80 (diff) | |
| download | pakakeh.go-7af6aa612bc60df120d7580c9e436b24d2326394.tar.xz | |
lib/paseto: rename the field Public and Private in Peer
Diffstat (limited to 'lib/paseto/v4/public_mode.go')
| -rw-r--r-- | lib/paseto/v4/public_mode.go | 14 |
1 files changed, 7 insertions, 7 deletions
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) } |
