Skip to content

Helpful library for sharing secret with using of Shamir's Secret Sharing

License

Notifications You must be signed in to change notification settings

AlekNS/go-sharedsecret

Repository files navigation

Go-SharedSecret - Helpful library for sharing a secret (WIP)

Build Status Go Report Card

Adapted Shamir's algorithm from the js implementation

Installation

Go get

go get github.com/alekns/go-sharedsecret

Features

Examples

Shamir Share

  secCtx := SecurityContext{8, 16, 128}
  svc := NewShareSecretByShamirSchema(NewShamirFullSecretFormatter(secCtx))
  parts, err := svc.Share("12345678", 3, 2, 128)

  // parts - slice of hex strings

Share secret with transformation

  // forward

  p1 := PipeTransform(
    InvertTransform(HexTransform()),
    CipherAESTransform("user1SecretKey"),
    Base64Transform())

  p2 := PipeTransform(
    InvertTransform(HexTransform()),
    CipherAESTransform("server1SecretKey"),
    HexTransform())

  p3 := PipeTransform(
    InvertTransform(HexTransform()),
    CipherAESTransform("server2SecretKey"),
    CipherAESTransform("globalkey"),
    Base64Transform())

  parts, err := svc.Share("12345678", 3, 2, 128)
  values, err := TransformShare(parts, p1, p2, p3)

  // backward (recovery secret from 2 parts)
  // use same p1, p2

  shares, err := TransformCombine(parts[:2], p1, p2)
  secret, err := svc.Combine(shares, 0)

About

Helpful library for sharing secret with using of Shamir's Secret Sharing

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages