WIP crypto prototyping
This commit is contained in:
@@ -31,6 +31,9 @@ import (
|
||||
crypto "github.com/libp2p/go-libp2p/core/crypto"
|
||||
routed "github.com/libp2p/go-libp2p/p2p/host/routed"
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
|
||||
agelib "filippo.io/age"
|
||||
"github.com/k4lipso/pentapass/crypto/age"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -99,7 +102,7 @@ func SetupLibp2pHost(ctx context.Context, dbPath string) (host host.Host, dht *d
|
||||
|
||||
type Peer struct {
|
||||
Id string
|
||||
//Todo: AgeKey Key
|
||||
Key string
|
||||
}
|
||||
|
||||
type NamespaceConfig struct {
|
||||
@@ -200,6 +203,7 @@ type Namespace struct {
|
||||
//Registry *sharedKeyRegistry
|
||||
CancelFunc context.CancelFunc
|
||||
ctx context.Context
|
||||
Key *agelib.X25519Identity
|
||||
}
|
||||
|
||||
|
||||
@@ -237,7 +241,15 @@ func (n *Namespace) List() {
|
||||
printErr(err)
|
||||
continue
|
||||
}
|
||||
fmt.Printf("[%s] -> %s\n", r.Key, string(r.Value))
|
||||
|
||||
val, err := age.Decrypt(r.Value, n.Key)
|
||||
|
||||
if err != nil {
|
||||
printErr(err)
|
||||
continue
|
||||
}
|
||||
|
||||
fmt.Printf("[%s] -> %s\n", r.Key, string(val))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,6 +264,7 @@ type StorageHandler struct {
|
||||
Host host.Host
|
||||
Ipfs *ipfslite.Peer
|
||||
PubSub *pubsub.PubSub
|
||||
Key *agelib.X25519Identity
|
||||
}
|
||||
|
||||
func IsTrustedPeer(ctx context.Context, id peer.ID, namespace string) bool {
|
||||
@@ -321,7 +334,7 @@ func CreateNamespace(ID string, storageHandler StorageHandler) (*Namespace, erro
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Namespace{ID: ID, Datastore: crdt, CancelFunc: psubCancel, ctx: storageHandler.Ctx}, nil
|
||||
return &Namespace{ID: ID, Datastore: crdt, CancelFunc: psubCancel, ctx: storageHandler.Ctx, Key: storageHandler.Key}, nil
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user