Rename node identity key and remove onion tests that arent really useful

This commit is contained in:
David Vennik
2023-01-10 19:47:19 +00:00
parent 614a5f6268
commit 0450421fc8
7 changed files with 38 additions and 592 deletions

View File

@@ -54,8 +54,8 @@ func New(tpt ifc.Transport, hdrPrv *prv.Key, no *node.Node,
nodes node.Nodes) (c *Client, e error) {
no.Transport = tpt
no.HeaderPrv = hdrPrv
no.HeaderPub = pub.Derive(hdrPrv)
no.IdentityPrv = hdrPrv
no.IdentityPub = pub.Derive(hdrPrv)
var ks *signer.KeySet
if _, ks, e = signer.New(); check(e) {
return
@@ -99,9 +99,9 @@ func (cl *Client) FindCloaked(clk cloak.PubKey) (hdr *prv.Key, pld *prv.Key,
var b cloak.Blinder
copy(b[:], clk[:cloak.BlindLen])
hash := cloak.Cloak(b, cl.Node.HeaderBytes)
hash := cloak.Cloak(b, cl.Node.IdentityBytes)
if hash == clk {
hdr = cl.Node.HeaderPrv
hdr = cl.Node.IdentityPrv
// there is no payload key for the node, only in sessions.
return
}
@@ -159,11 +159,11 @@ func (cl *Client) SendKeys(nodeID []nonce.ID, hook confirm.Hook) (conf nonce.ID,
// cl.Sessions.Add(&session.Session{
// ID: n.ID,
// Remaining: 1 << 16,
// HeaderPub: hdrPub,
// HeaderBytes: hdrPub.ToBytes(),
// IdentityPub: hdrPub,
// IdentityBytes: hdrPub.ToBytes(),
// PayloadPub: pldPub,
// PayloadBytes: pldPub.ToBytes(),
// HeaderPrv: hdrPrv,
// IdentityPrv: hdrPrv,
// PayloadPrv: pldPrv,
// Deadline: time.Now().Add(DefaultDeadline),
// })

View File

@@ -60,7 +60,6 @@ func TestPing(t *testing.T) {
}
}
//
// func TestSendKeys(t *testing.T) {
// const nTotal = 6
// clients := make([]*Client, nTotal)

View File

@@ -1,38 +0,0 @@
package client
import (
"math/rand"
"github.com/indra-labs/indra/pkg/node"
"github.com/indra-labs/indra/pkg/slice"
)
// SimpleSelector is a pure random shuffle selection algorithm for producing
// a list of nodes for an onion.
//
// This function will return nil if there isn't enough
func SimpleSelector(n node.Nodes, exit *node.Node,
count int) (selected node.Nodes) {
// For the purposes of this simple selector algorithm we require unique
// nodes for each hop.
if len(n) < count+1 {
log.E.F("not enough nodes, have %d, need %d", len(n), count+1)
return
}
// Remove the exit from the list of options.
var nCandidates node.Nodes
if exit != nil {
for i := range n {
if n[i].ID != exit.ID {
nCandidates = append(nCandidates, n[i])
}
}
}
// Shuffle the list we made
rand.Seed(slice.GetCryptoRandSeed())
rand.Shuffle(len(nCandidates), func(i, j int) {
nCandidates[i], nCandidates[j] = nCandidates[j], nCandidates[i]
})
return nCandidates[:count]
}

View File

@@ -27,13 +27,13 @@ var (
// this except when the netip.AddrPort is known via the packet sender address.
type Node struct {
nonce.ID
Addr string
AddrPort *netip.AddrPort
HeaderPub *pub.Key
HeaderBytes pub.Bytes
HeaderPrv *prv.Key
PingCount int
LastSeen time.Time
Addr string
AddrPort *netip.AddrPort
IdentityPub *pub.Key
IdentityBytes pub.Bytes
IdentityPrv *prv.Key
PingCount int
LastSeen time.Time
Services
ifc.Transport
}
@@ -45,13 +45,13 @@ func New(addr *netip.AddrPort, hdr *pub.Key, hdrPrv *prv.Key,
id = nonce.NewID()
n = &Node{
ID: id,
Addr: addr.String(),
AddrPort: addr,
Transport: tpt,
HeaderPub: hdr,
HeaderBytes: hdr.ToBytes(),
HeaderPrv: hdrPrv,
ID: id,
Addr: addr.String(),
AddrPort: addr,
Transport: tpt,
IdentityPub: hdr,
IdentityBytes: hdr.ToBytes(),
IdentityPrv: hdrPrv,
}
return
}

View File

@@ -26,13 +26,13 @@ func Ping(id nonce.ID, client *node.Node, hop [3]*node.Node,
n := GenPingNonces()
return OnionSkins{}.
Forward(hop[0].AddrPort).
OnionSkin(hop[0].HeaderPub, set.Next(), n[0]).
OnionSkin(hop[0].IdentityPub, set.Next(), n[0]).
Forward(hop[1].AddrPort).
OnionSkin(hop[1].HeaderPub, set.Next(), n[1]).
OnionSkin(hop[1].IdentityPub, set.Next(), n[1]).
Forward(hop[2].AddrPort).
OnionSkin(hop[2].HeaderPub, set.Next(), n[2]).
OnionSkin(hop[2].IdentityPub, set.Next(), n[2]).
Forward(client.AddrPort).
OnionSkin(client.HeaderPub, set.Next(), n[3]).
OnionSkin(client.IdentityPub, set.Next(), n[3]).
Confirmation(id)
}
@@ -49,28 +49,28 @@ func Ping(id nonce.ID, client *node.Node, hop [3]*node.Node,
// This message's last layer is a Confirmation, which allows the client to know
// that the key was successfully delivered to the Reverse relays that will be
// used in the Purchase.
func SendKeys(id nonce.ID, hdr, pld [5]*prv.Key,
client *node.Node, hop [5]*node.Node, set *signer.KeySet) OnionSkins {
func SendKeys(id nonce.ID, hdr, pld []*prv.Key,
client *node.Node, hop []*node.Node, set *signer.KeySet) OnionSkins {
n := GenNonces(6)
return OnionSkins{}.
Forward(hop[0].AddrPort).
OnionSkin(hop[0].HeaderPub, set.Next(), n[0]).
OnionSkin(hop[0].IdentityPub, set.Next(), n[0]).
Cipher(hdr[0], pld[0]).
Forward(hop[1].AddrPort).
OnionSkin(hop[1].HeaderPub, set.Next(), n[1]).
OnionSkin(hop[1].IdentityPub, set.Next(), n[1]).
Cipher(hdr[1], pld[1]).
Forward(hop[2].AddrPort).
OnionSkin(hop[2].HeaderPub, set.Next(), n[2]).
OnionSkin(hop[2].IdentityPub, set.Next(), n[2]).
Cipher(hdr[2], pld[2]).
Forward(hop[3].AddrPort).
OnionSkin(hop[3].HeaderPub, set.Next(), n[3]).
OnionSkin(hop[3].IdentityPub, set.Next(), n[3]).
Cipher(hdr[3], pld[3]).
Forward(hop[4].AddrPort).
OnionSkin(hop[4].HeaderPub, set.Next(), n[4]).
OnionSkin(hop[4].IdentityPub, set.Next(), n[4]).
Cipher(hdr[4], pld[4]).
Forward(client.AddrPort).
OnionSkin(client.HeaderPub, set.Next(), n[5]).
OnionSkin(client.IdentityPub, set.Next(), n[5]).
Confirmation(id)
}
@@ -105,11 +105,11 @@ func SendExit(payload slice.Bytes, port uint16, client *node.Node,
pubs[2] = sess[2].PayloadPub
return OnionSkins{}.
Forward(hop[0].AddrPort).
OnionSkin(hop[0].HeaderPub, set.Next(), n0[0]).
OnionSkin(hop[0].IdentityPub, set.Next(), n0[0]).
Forward(hop[1].AddrPort).
OnionSkin(hop[1].HeaderPub, set.Next(), n0[1]).
OnionSkin(hop[1].IdentityPub, set.Next(), n0[1]).
Forward(hop[2].AddrPort).
OnionSkin(hop[2].HeaderPub, set.Next(), n0[2]).
OnionSkin(hop[2].IdentityPub, set.Next(), n0[2]).
Exit(port, prvs, pubs, n1, payload).
Reverse(hop[3].AddrPort).
OnionSkin(sess[0].HeaderPub, prvs[0], n1[0]).

View File

@@ -1,515 +0,0 @@
package wire
import (
"math/rand"
"reflect"
"testing"
"time"
"github.com/indra-labs/indra/pkg/key/pub"
"github.com/indra-labs/indra/pkg/key/signer"
"github.com/indra-labs/indra/pkg/node"
"github.com/indra-labs/indra/pkg/nonce"
"github.com/indra-labs/indra/pkg/session"
"github.com/indra-labs/indra/pkg/sha256"
"github.com/indra-labs/indra/pkg/slice"
"github.com/indra-labs/indra/pkg/testutils"
"github.com/indra-labs/indra/pkg/types"
"github.com/indra-labs/indra/pkg/wire/confirm"
"github.com/indra-labs/indra/pkg/wire/exit"
"github.com/indra-labs/indra/pkg/wire/forward"
"github.com/indra-labs/indra/pkg/wire/layer"
"github.com/indra-labs/indra/pkg/wire/reverse"
)
func PeelForward(t *testing.T, b slice.Bytes,
c *slice.Cursor) (fwd *forward.OnionSkin) {
var ok bool
var on types.Onion
var e error
if on, e = PeelOnion(b, c); check(e) {
t.Error(e)
}
if fwd, ok = on.(*forward.OnionSkin); !ok {
t.Error("did not unwrap expected type", reflect.TypeOf(fwd))
}
return
}
func PeelOnionSkin(t *testing.T, b slice.Bytes,
c *slice.Cursor) (l *layer.OnionSkin) {
var ok bool
var on types.Onion
var e error
if on, e = PeelOnion(b, c); check(e) {
t.Error(e)
}
if l, ok = on.(*layer.OnionSkin); !ok {
t.Error("did not unwrap expected type", reflect.TypeOf(l))
}
return
}
func PeelConfirmation(t *testing.T, b slice.Bytes,
c *slice.Cursor) (cn *confirm.OnionSkin) {
var ok bool
var e error
var on types.Onion
if on, e = PeelOnion(b, c); check(e) {
t.Error(e)
}
if cn, ok = on.(*confirm.OnionSkin); !ok {
t.Error("did not unwrap expected type", reflect.TypeOf(on))
}
return
}
func PeelReverse(t *testing.T, b slice.Bytes,
c *slice.Cursor) (rp *reverse.OnionSkin) {
var ok bool
var e error
var on types.Onion
if on, e = PeelOnion(b, c); check(e) {
t.Error(e)
}
if rp, ok = on.(*reverse.OnionSkin); !ok {
t.Error("did not unwrap expected type", reflect.TypeOf(on))
}
return
}
func PeelExit(t *testing.T, b slice.Bytes,
c *slice.Cursor) (ex *exit.OnionSkin) {
var ok bool
var e error
var on types.Onion
if on, e = PeelOnion(b, c); check(e) {
t.Error(e)
t.FailNow()
}
if ex, ok = on.(*exit.OnionSkin); !ok {
t.Error("did not unwrap expected type", reflect.TypeOf(on))
t.FailNow()
}
return
}
func TestPing(t *testing.T) {
_, ks, e := signer.New()
if check(e) {
t.Error(e)
t.FailNow()
}
var hop [3]*node.Node
for i := range hop {
prv1, _ := GetTwoPrvKeys(t)
pub1 := pub.Derive(prv1)
var n nonce.ID
hop[i], n = node.New(slice.GenerateRandomAddrPortIPv4(),
pub1, prv1, nil)
_ = n
}
cprv1, _ := GetTwoPrvKeys(t)
cpub1 := pub.Derive(cprv1)
var n nonce.ID
var client *node.Node
client, n = node.New(slice.GenerateRandomAddrPortIPv4(),
cpub1, cprv1, nil)
on := Ping(n, client, hop, ks)
b := EncodeOnion(on.Assemble())
c := slice.NewCursor()
// Forward(hop[0].AddrPort).
f0 := PeelForward(t, b, c)
if hop[0].AddrPort.String() != f0.AddrPort.String() {
t.Errorf("failed to unwrap; expected: '%s', got: '%s'",
hop[0].AddrPort.String(), f0.AddrPort.String())
t.FailNow()
}
// OnionSkin(address.FromPubKey(hop[0].HeaderPub), set.Next()).
PeelOnionSkin(t, b, c).Decrypt(hop[0].HeaderPrv, b, c)
// Forward(hop[1].AddrPort).
f1 := PeelForward(t, b, c)
if hop[1].AddrPort.String() != f1.AddrPort.String() {
t.Errorf("failed to unwrap; expected: '%s', got: '%s'",
hop[1].AddrPort.String(), f1.AddrPort.String())
t.FailNow()
}
// OnionSkin(address.FromPubKey(hop[1].HeaderPub), set.Next()).
PeelOnionSkin(t, b, c).Decrypt(hop[1].HeaderPrv, b, c)
// Forward(hop[2].AddrPort).
f2 := PeelForward(t, b, c)
if hop[2].AddrPort.String() != f2.AddrPort.String() {
t.Errorf("failed to unwrap; expected: '%s', got: '%s'",
hop[2].AddrPort.String(), f2.AddrPort.String())
t.FailNow()
}
// OnionSkin(address.FromPubKey(hop[2].HeaderPub), set.Next()).
PeelOnionSkin(t, b, c).Decrypt(hop[2].HeaderPrv, b, c)
// Forward(client.AddrPort).
f3 := PeelForward(t, b, c)
if client.AddrPort.String() != f3.AddrPort.String() {
t.Errorf("failed to unwrap; expected: '%s', got: '%s'",
client.AddrPort.String(), f3.AddrPort.String())
t.FailNow()
}
// OnionSkin(address.FromPubKey(client.HeaderPub), set.Next()).
PeelOnionSkin(t, b, c).Decrypt(client.HeaderPrv, b, c)
// Confirmation(id).
co := PeelConfirmation(t, b, c)
if co.ID != n {
t.Error("did not unwrap expected confirmation nonce")
t.FailNow()
}
}
//
// func TestSendKeys(t *testing.T) {
//
// _, ks, e := signer.New()
// if check(e) {
// t.Error(e)
// t.FailNow()
// }
// var hop [5]*node.Node
// for i := range hop {
// prv1, _ := GetTwoPrvKeys(t)
// pub1 := pub.Derive(prv1)
// hop[i], _ = node.New(slice.GenerateRandomAddrPortIPv4(),
// pub1, prv1, nil)
// }
// cprv1, _ := GetTwoPrvKeys(t)
// cpub1 := pub.Derive(cprv1)
// var n nonce.ID
// var client *node.Node
// client, n = node.New(slice.GenerateRandomAddrPortIPv4(),
// cpub1, cprv1, nil)
// ciprv1, ciprv2 := GetTwoPrvKeys(t)
// // cipub1, cipub2 := pub.Derive(ciprv1), pub.Derive(ciprv2)
//
// on := SendKeys(n, ciprv1, ciprv2, client, hop, ks)
// b := EncodeOnion(on.Assemble())
// c := slice.NewCursor()
// var ok bool
//
// // Forward(hop[0].AddrPort).
// f0 := PeelForward(t, b, c)
// if hop[0].AddrPort.String() != f0.AddrPort.String() {
// t.Errorf("failed to unwrap expected: '%s', got '%s'",
// hop[0].AddrPort.String(), f0.AddrPort.String())
// t.FailNow()
// }
//
// // OnionSkin(address.FromPubKey(hop[0].HeaderPub), set.Next()).
// PeelOnionSkin(t, b, c).Decrypt(hop[0].HeaderPrv, b, c)
//
// // Forward(hop[1].AddrPort).
// f1 := PeelForward(t, b, c)
// if hop[1].AddrPort.String() != f1.AddrPort.String() {
// t.Errorf("failed to unwrap expected: '%s', got '%s'",
// hop[1].AddrPort.String(), f1.AddrPort.String())
// t.FailNow()
// }
//
// // OnionSkin(address.FromPubKey(hop[1].HeaderPub), set.Next()).
// PeelOnionSkin(t, b, c).Decrypt(hop[1].HeaderPrv, b, c)
//
// // Forward(hop[2].AddrPort).
// f2 := PeelForward(t, b, c)
// if hop[2].AddrPort.String() != f2.AddrPort.String() {
// t.Errorf("failed to unwrap expected: '%s', got '%s'",
// hop[2].AddrPort.String(), f2.AddrPort.String())
// t.FailNow()
// }
//
// // OnionSkin(address.FromPubKey(hop[2].HeaderPub), set.Next()).
// PeelOnionSkin(t, b, c).Decrypt(hop[2].HeaderPrv, b, c)
//
// // Cipher(hdr, pld).
// var onc types.Onion
// if onc, e = PeelOnion(b, c); check(e) {
// t.Error(e)
// t.FailNow()
// }
// var ci *cipher.OnionSkin
// if ci, ok = onc.(*cipher.OnionSkin); !ok {
// t.Error("did not unwrap expected type", reflect.TypeOf(onc))
// t.FailNow()
// }
// if !ci.Header.Key.Equals(&ciprv1.Key) {
// t.Error("did not unwrap header key")
// t.FailNow()
// }
// if !ci.Payload.Key.Equals(&ciprv2.Key) {
// t.Error("did not unwrap payload key")
// t.FailNow()
// }
//
// // Forward(hop[3].AddrPort).
// f3 := PeelForward(t, b, c)
// if hop[3].AddrPort.String() != f3.AddrPort.String() {
// t.Errorf("failed to unwrap expected: '%s', got '%s'",
// hop[3].AddrPort.String(), f3.AddrPort.String())
// t.FailNow()
// }
//
// // OnionSkin(address.FromPubKey(hop[3].HeaderPub), set.Next()).
// PeelOnionSkin(t, b, c).Decrypt(hop[3].HeaderPrv, b, c)
//
// // Forward(hop[4].AddrPort).
// f4 := PeelForward(t, b, c)
// if hop[4].AddrPort.String() != f4.AddrPort.String() {
// t.Errorf("failed to unwrap expected: '%s', got '%s'",
// hop[3].AddrPort.String(), f4.AddrPort.String())
// t.FailNow()
// }
//
// // OnionSkin(address.FromPubKey(hop[4].HeaderPub), set.Next()).
// PeelOnionSkin(t, b, c).Decrypt(hop[4].HeaderPrv, b, c)
//
// // Forward(client.AddrPort).
// f5 := PeelForward(t, b, c)
// if client.AddrPort.String() != f5.AddrPort.String() {
// t.Errorf("failed to unwrap expected: '%s', got '%s'",
// client.AddrPort.String(), f5.AddrPort.String())
// t.FailNow()
// }
//
// // OnionSkin(address.FromPubKey(client.HeaderPub), set.Next()).
// PeelOnionSkin(t, b, c).Decrypt(client.HeaderPrv, b, c)
//
// // Confirmation(id).
// co := PeelConfirmation(t, b, c)
// if co.ID != n {
// t.Error("did not unwrap expected confirmation nonce")
// t.FailNow()
//
// }
//
// }
//
// func TestSendPurchase(t *testing.T) {
//
// log2.SetLogLevel(log2.Trace)
// _, ks, e := signer.New()
// if check(e) {
// t.Error(e)
// t.FailNow()
// }
// var hop [5]*node.Node
// for i := range hop {
// prv1, _ := GetTwoPrvKeys(t)
// pub1 := pub.Derive(prv1)
// hop[i], _ = node.New(slice.GenerateRandomAddrPortIPv4(),
// pub1, prv1, nil)
// }
// cprv1, _ := GetTwoPrvKeys(t)
// cpub1 := pub.Derive(cprv1)
// var client *node.Node
// client, _ = node.New(slice.GenerateRandomAddrPortIPv4(),
// cpub1, cprv1, nil)
// var sess [3]*session.Session
// for i := range sess {
// sess[i] = session.New(nonce.NewID(), 203230230, time.Hour)
// }
// nBytes := rand.Uint64()
// n := nonce.NewID()
// on := SendPurchase(n, nBytes, client, hop, sess, ks)
// b := EncodeOnion(on.Assemble())
// c := slice.NewCursor()
//
// // Forward(hop[0].AddrPort).
// f0 := PeelForward(t, b, c)
// if hop[0].AddrPort.String() != f0.AddrPort.String() {
// t.Errorf("failed to unwrap expected: '%s', got '%s'",
// hop[0].AddrPort.String(), f0.AddrPort.String())
// t.FailNow()
// }
//
// // OnionSkin(address.FromPubKey(hop[0].HeaderPub), set.Next()).
// PeelOnionSkin(t, b, c).Decrypt(hop[0].HeaderPrv, b, c)
//
// // Forward(hop[1].AddrPort).
// f1 := PeelForward(t, b, c)
// if hop[1].AddrPort.String() != f1.AddrPort.String() {
// t.Errorf("failed to unwrap expected: '%s', got '%s'",
// hop[0].AddrPort.String(), f1.AddrPort.String())
// t.FailNow()
// }
//
// // OnionSkin(address.FromPubKey(hop[1].HeaderPub), set.Next()).
// PeelOnionSkin(t, b, c).Decrypt(hop[1].HeaderPrv, b, c)
//
// // Forward(hop[2].AddrPort).
// f2 := PeelForward(t, b, c)
// if hop[2].AddrPort.String() != f2.AddrPort.String() {
// t.Errorf("failed to unwrap expected: '%s', got '%s'",
// hop[1].AddrPort.String(), f1.AddrPort.String())
// t.FailNow()
// }
//
// // OnionSkin(address.FromPubKey(hop[2].HeaderPub), set.Next()).
// PeelOnionSkin(t, b, c).Decrypt(hop[2].HeaderPrv, b, c)
//
// // Purchase(nBytes, prvs, pubs).
// pr := PeelPurchase(t, b, c)
// if pr.NBytes != nBytes {
// t.Errorf("failed to retrieve original purchase nBytes")
// t.FailNow()
// }
//
// // Reverse(hop[3].AddrPort).
// rp1 := PeelReverse(t, b, c)
// if rp1.AddrPort.String() != hop[3].AddrPort.String() {
// t.Errorf("failed to retrieve first reply hop")
// t.FailNow()
// }
//
// // OnionSkin(address.FromPubKey(hop[3].HeaderPub), replies[0]).
// PeelOnionSkin(t, b, c).Decrypt(sess[0].HeaderPrv, b, c)
//
// // Reverse(hop[4].AddrPort).
// rp2 := PeelReverse(t, b, c)
// if rp2.AddrPort.String() != hop[4].AddrPort.String() {
// t.Errorf("failed to retrieve second reply hop")
// t.FailNow()
// }
//
// // OnionSkin(address.FromPubKey(hop[4].HeaderPub), replies[1]).
// PeelOnionSkin(t, b, c).Decrypt(sess[1].HeaderPrv, b, c)
//
// // Reverse(client.AddrPort).
// rp3 := PeelReverse(t, b, c)
// if rp3.AddrPort.String() != client.AddrPort.String() {
// t.Errorf("failed to retrieve third reply hop")
// t.FailNow()
// }
//
// // OnionSkin(address.FromPubKey(client.HeaderPub), replies[2]).
// PeelOnionSkin(t, b, c).Decrypt(sess[2].HeaderPrv, b, c)
//
// }
func TestSendExit(t *testing.T) {
_, ks, e := signer.New()
if check(e) {
t.Error(e)
t.FailNow()
}
var hop [5]*node.Node
for i := range hop {
prv1, _ := GetTwoPrvKeys(t)
pub1 := pub.Derive(prv1)
hop[i], _ = node.New(slice.GenerateRandomAddrPortIPv4(),
pub1, prv1, nil)
}
cprv1, _ := GetTwoPrvKeys(t)
cpub1 := pub.Derive(cprv1)
var client *node.Node
client, _ = node.New(slice.GenerateRandomAddrPortIPv4(),
cpub1, cprv1, nil)
port := uint16(rand.Uint32())
var message slice.Bytes
var hash sha256.Hash
message, hash, e = testutils.GenerateTestMessage(2502)
var sess [3]*session.Session
for i := range sess {
sess[i] = session.New(nonce.NewID(), 203230230, time.Hour)
}
on := SendExit(message, port, client, hop, sess, ks)
b := EncodeOnion(on.Assemble())
c := slice.NewCursor()
// Forward(hop[0].AddrPort).
f0 := PeelForward(t, b, c)
if hop[0].AddrPort.String() != f0.AddrPort.String() {
t.Errorf("failed to unwrap expected: '%s', got '%s'",
hop[0].AddrPort.String(), f0.AddrPort.String())
t.FailNow()
}
// OnionSkin(address.FromPubKey(hop[0].HeaderPub), set.Next()).
PeelOnionSkin(t, b, c).Decrypt(hop[0].HeaderPrv, b, c)
// Forward(hop[1].AddrPort).
f1 := PeelForward(t, b, c)
if hop[1].AddrPort.String() != f1.AddrPort.String() {
t.Errorf("failed to unwrap expected: '%s', got '%s'",
hop[0].AddrPort.String(), f1.AddrPort.String())
t.FailNow()
}
// OnionSkin(address.FromPubKey(hop[1].HeaderPub), set.Next()).
PeelOnionSkin(t, b, c).Decrypt(hop[1].HeaderPrv, b, c)
// Forward(hop[2].AddrPort).
f2 := PeelForward(t, b, c)
if hop[2].AddrPort.String() != f2.AddrPort.String() {
t.Errorf("failed to unwrap expected: '%s', got '%s'",
hop[1].AddrPort.String(), f1.AddrPort.String())
t.FailNow()
}
// OnionSkin(address.FromPubKey(hop[2].HeaderPub), set.Next()).
PeelOnionSkin(t, b, c).Decrypt(hop[2].HeaderPrv, b, c)
// Exit(port, prvs, pubs, payload).
pr := PeelExit(t, b, c)
if pr.Port != port {
t.Errorf("failed to retrieve original purchase nBytes")
t.FailNow()
}
mh := sha256.Single(pr.Bytes)
if mh != hash {
t.Errorf("exit message not correctly decoded")
t.FailNow()
}
// Reverse(hop[3].AddrPort).
rp1 := PeelReverse(t, b, c)
if rp1.AddrPort.String() != hop[3].AddrPort.String() {
t.Errorf("failed to retrieve first reply hop")
t.FailNow()
}
// OnionSkin(address.FromPubKey(hop[3].HeaderPub), replies[0]).
PeelOnionSkin(t, b, c).Decrypt(sess[0].HeaderPrv, b, c)
// Reverse(hop[4].AddrPort).
rp2 := PeelReverse(t, b, c)
if rp2.AddrPort.String() != hop[4].AddrPort.String() {
t.Errorf("failed to retrieve second reply hop")
t.FailNow()
}
// OnionSkin(address.FromPubKey(hop[4].HeaderPub), replies[1]).
PeelOnionSkin(t, b, c).Decrypt(sess[1].HeaderPrv, b, c)
// Reverse(client.AddrPort).
rp3 := PeelReverse(t, b, c)
if rp3.AddrPort.String() != client.AddrPort.String() {
t.Errorf("failed to retrieve third reply hop")
t.FailNow()
}
// OnionSkin(address.FromPubKey(client.HeaderPub), replies[2]).
PeelOnionSkin(t, b, c).Decrypt(sess[2].HeaderPrv, b, c)
}

View File

@@ -10,9 +10,9 @@ var (
// GitRef is the gitref, as in refs/heads/branchname.
GitRef = "refs/heads/protocol"
// ParentGitCommit is the commit hash of the parent HEAD.
ParentGitCommit = "c2fe57e3955e4401c1fef996c9145ffe402b1e68"
ParentGitCommit = "a2ba626e71bf72a88b7a97e05f6f40dc9c21a14f"
// BuildTime stores the time when the current binary was built.
BuildTime = "2023-01-10T19:21:22Z"
BuildTime = "2023-01-10T19:47:19Z"
// SemVer lists the (latest) git tag on the release.
SemVer = "v0.1.7"
// PathBase is the path base returned from runtime caller.