endpoint: add option WithSecretKey #30

Merged
decentral1se merged 1 commits from OptionWithSecretKey into main 2026-11-09 13:56:15 +00:00
Collaborator

lil expansion to the options to so that it is easy to use it for adding a static secret key

  • no use of so-called 'AI'
lil expansion to the options to so that it is easy to use it for adding a static secret key - [x] no use of so-called 'AI'
cblgh added 1 commit 2026-11-09 13:53:46 +00:00
endpoint: add option WithSecretKey
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
f4294327b4
decentral1se left a comment
Owner

Haha, very nice! I was just thinking to add this in another changeset 🥇

Haha, very nice! I was just thinking to add this in another changeset 🥇
decentral1se merged commit af23ad2371 into main 2026-11-09 13:56:15 +00:00
Author
Collaborator

what i normally do for this is actually a bit more specific, but i don't think it fits as an endpoint option:

digest := sha256.Sum256([]byte(stringVar))
secretBytes := digest[:] // copy out bytes from strict [32]byte type to []byte used by everything else + iroh
ep, err := endpoint.New(WithSecretKey(secretBytes))

i wonder, should we create a util package for standalone useful snippets like the above? e.g:

func SecretBytesFromString(str string) []byte {
    // TODO (2026-11-09): securely clear all arrays to the extent possible
    digest := sha256.Sum256([]byte(str))
    return digest[:] // copy out bytes from strict [32]byte type to []byte used by everything else + iroh
}
what i normally do for this is actually a bit more specific, but i don't think it fits as an endpoint option: ```golang digest := sha256.Sum256([]byte(stringVar)) secretBytes := digest[:] // copy out bytes from strict [32]byte type to []byte used by everything else + iroh ep, err := endpoint.New(WithSecretKey(secretBytes)) ``` i wonder, should we create a util package for standalone useful snippets like the above? e.g: ```golang func SecretBytesFromString(str string) []byte { // TODO (2026-11-09): securely clear all arrays to the extent possible digest := sha256.Sum256([]byte(str)) return digest[:] // copy out bytes from strict [32]byte type to []byte used by everything else + iroh }
Author
Collaborator

ping @decentral1se with comment above, you were fast! XD

ping @decentral1se with comment above, you were fast! XD
Owner

Nice, yeh, whatever you want to upstream, go for it ⏫ I generally skirt around a vague utils package and just make tiny specific ones (e.g. a keys/keys.go for a keys.SecretBytesFromString API) but I've not got strong feelings about this!

Nice, yeh, whatever you want to upstream, go for it ⏫ I generally skirt around a vague `utils` package and just make tiny specific ones (e.g. a `keys/keys.go` for a `keys.SecretBytesFromString` API) but I've not got strong feelings about this!
Author
Collaborator

haha INTERESTING, i usually love a big chunky util and toss everything in there XD then refactor into e.g. your keys/keys.go if need be. case in point https://github.com/cblgh/cerca/blob/main/util/eout/eout.go)

imma go with my approach then since you have no super strong opinion 🐶

haha INTERESTING, i usually love a big chunky util and toss everything in there XD then refactor into e.g. your `keys/keys.go` if need be. case in point https://github.com/cblgh/cerca/blob/main/util/eout/eout.go) imma go with my approach then since you have no super strong opinion 🐶
cblgh deleted branch OptionWithSecretKey 2026-11-09 14:14:05 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: decentral1se/iroh-go#30