MCPcopy Create free account
hub / github.com/encodeous/nylon / OpenBundle

Function OpenBundle

state/distribution.go:50–65  ·  view source on GitHub ↗
(data []byte, key []byte)

Source from the content-addressed store, hash-verified

48}
49
50func OpenBundle(data []byte, key []byte) ([]byte, error) {
51 if len(data) < chacha20poly1305.NonceSizeX {
52 return nil, errors.New("invalid bundle, too small")
53 }
54 ahead, err := chacha20poly1305.NewX(key[:])
55 if err != nil {
56 return nil, err
57 }
58 nonce := data[:chacha20poly1305.NonceSizeX]
59 cipherText := data[chacha20poly1305.NonceSizeX:]
60 bundle, err := ahead.Open(make([]byte, 0), nonce, cipherText, make([]byte, 0))
61 if err != nil {
62 return nil, err
63 }
64 return bundle, nil
65}
66
67// BundleConfig first signs the config with the root private key, ensuring the authenticity, then encrypts the message using the bytes of the root public key as the shared key, offering some level of privacy. (assuming the root public key is not shared widely)
68func BundleConfig(config string, rootKey NyPrivateKey) (string, error) {

Callers 1

UnbundleConfigFunction · 0.85

Calls 1

OpenMethod · 0.65

Tested by

no test coverage detected