Documentation ¶
Index ¶
- func Base64ImageToByteArray(image_base64encoded string) ([]byte, error)
- func CommaSeperatedIndicesArray(s string) ([]int, error)
- func G(InputBytes []byte) []byte
- func H(InputBytes []byte) []byte
- type JohnsonMerkleSignature
- func (sig *JohnsonMerkleSignature) Marshal() (string, error)
- func (orig_signature *JohnsonMerkleSignature) Redact(redacted_indices []int, data *PartitionedData) (RedactableSignature, error)
- func (sig *JohnsonMerkleSignature) Sign(data *PartitionedData, private_key *crypto.PrivateKey) error
- func (sig *JohnsonMerkleSignature) Unmarshal(input string) error
- func (sig *JohnsonMerkleSignature) Verify(data *PartitionedData) error
- type JohnsonRSASignature
- func (sig *JohnsonRSASignature) Marshal() (string, error)
- func (sig *JohnsonRSASignature) Redact(redacted_indices []int, data *PartitionedData) (RedactableSignature, error)
- func (sig *JohnsonRSASignature) Sign(data *PartitionedData, private_key *crypto.PrivateKey) error
- func (sig *JohnsonRSASignature) Unmarshal(input string) error
- func (sig *JohnsonRSASignature) Verify(data *PartitionedData) error
- type NaiveSignature
- func (sig *NaiveSignature) Marshal() (string, error)
- func (sig *NaiveSignature) Redact(redacted_indices []int, data *PartitionedData) (RedactableSignature, error)
- func (sig *NaiveSignature) Sign(data *PartitionedData, private_key *crypto.PrivateKey) error
- func (sig *NaiveSignature) Unmarshal(sig_string string) error
- func (sig *NaiveSignature) Verify(data *PartitionedData) error
- type PartitionedData
- func (c PartitionedData) GetRedactedIndicesArray() []int
- func (c PartitionedData) Hash() []byte
- func (c PartitionedData) Marshal() (string, error)
- func (c PartitionedData) Redact(redacted_indices []int) (*PartitionedData, error)
- func (c PartitionedData) ToByteArray() []byte
- func (c PartitionedData) ToDataURL(chunksX int, chunksY int) (string, error)
- func (c PartitionedData) ToDataURLs() []string
- func (c PartitionedData) ToImage(chunksX int, chunksY int) (image.Image, error)
- type RedactableSignature
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base64ImageToByteArray ¶
Base64ImageToByteArray converts a base64-encoded image and converts it to a byte array.
func CommaSeperatedIndicesArray ¶
CommaSeperatedIndicesArray takes a comma seperated string of indices and converts it into a slice of indices.
Types ¶
type JohnsonMerkleSignature ¶
type JohnsonMerkleSignature struct { BaseSignature []byte PublicKey ecdsa.PublicKey Key []byte // This is only visible before the redaction RedactedKeys map[string]redactedProperty // And this afterwards, these are the conodes keys RedactedHash map[string]redactedProperty // and these the hashes of the parents of the redacted nodes }
func (*JohnsonMerkleSignature) Marshal ¶
func (sig *JohnsonMerkleSignature) Marshal() (string, error)
func (*JohnsonMerkleSignature) Redact ¶
func (orig_signature *JohnsonMerkleSignature) Redact(redacted_indices []int, data *PartitionedData) (RedactableSignature, error)
Redacts an existing signature based on data. When redacting, k_epsilon is not publicsed, as with it we could just calculate all the hashes and possibly get access to the redacted data by bruteforcing or similar. Instead, we just publicise the co-nodes keys, as well as the parent node of the redacted leaf
func (*JohnsonMerkleSignature) Sign ¶ added in v0.2.0
func (sig *JohnsonMerkleSignature) Sign(data *PartitionedData, private_key *crypto.PrivateKey) error
Sign uses the private_key to sign data redactably.
func (*JohnsonMerkleSignature) Unmarshal ¶ added in v0.2.0
func (sig *JohnsonMerkleSignature) Unmarshal(input string) error
func (*JohnsonMerkleSignature) Verify ¶
func (sig *JohnsonMerkleSignature) Verify(data *PartitionedData) error
Verifies if a given signature matches the supplied data This rebuilds the tree by regenerating the co-node-trees, as well as using the supplied hashes to retrieve the root node hash
type JohnsonRSASignature ¶
type JohnsonRSASignature struct { DocumentKey []byte BaseSignature big.Int Generator big.Int PublicKey rsa.PublicKey }
func (*JohnsonRSASignature) Marshal ¶
func (sig *JohnsonRSASignature) Marshal() (string, error)
func (*JohnsonRSASignature) Redact ¶
func (sig *JohnsonRSASignature) Redact(redacted_indices []int, data *PartitionedData) (RedactableSignature, error)
Redacts an existing signature by mutliplying it with the removed hashes
func (*JohnsonRSASignature) Sign ¶ added in v0.2.0
func (sig *JohnsonRSASignature) Sign(data *PartitionedData, private_key *crypto.PrivateKey) error
Signs the input data according to the paper
func (*JohnsonRSASignature) Unmarshal ¶ added in v0.2.0
func (sig *JohnsonRSASignature) Unmarshal(input string) error
func (*JohnsonRSASignature) Verify ¶
func (sig *JohnsonRSASignature) Verify(data *PartitionedData) error
Verifies a signature according to the paper
type NaiveSignature ¶
type NaiveSignature struct { Identifier []byte Length int BaseSignature []byte Signatures [][]byte PublicKey ecdsa.PublicKey }
func (*NaiveSignature) Marshal ¶
func (sig *NaiveSignature) Marshal() (string, error)
func (*NaiveSignature) Redact ¶ added in v0.2.0
func (sig *NaiveSignature) Redact(redacted_indices []int, data *PartitionedData) (RedactableSignature, error)
func (*NaiveSignature) Sign ¶ added in v0.2.0
func (sig *NaiveSignature) Sign(data *PartitionedData, private_key *crypto.PrivateKey) error
func (*NaiveSignature) Unmarshal ¶ added in v0.2.0
func (sig *NaiveSignature) Unmarshal(sig_string string) error
func (*NaiveSignature) Verify ¶
func (sig *NaiveSignature) Verify(data *PartitionedData) error
type PartitionedData ¶
type PartitionedData [][]byte
PartitionedData is a wrapper for the input data to sign. Depending on the structure of the data at hand, you might want to choose a different partition: E.g. a partition for each field of a formular, or each word in a text. Depending on the signature scheme you use, the amount of partitions can have an impact on the size and performance.
func ImageToPartitionedData ¶
ImagetoPartitionedData converts a html-base64 encoded image into a chunk array with chunksX * chunksY resolution.
func StringToPartitionedData ¶
func StringToPartitionedData(s string) *PartitionedData
StringToPartitionedData partitions a string s word-wise
func UnmarshalPartitionedData ¶
func UnmarshalPartitionedData(s string) (*PartitionedData, error)
UnmarshalPartitionedData unmarshales a JSON/base64 encoded representation of the partitioned data.
func (PartitionedData) GetRedactedIndicesArray ¶
func (c PartitionedData) GetRedactedIndicesArray() []int
GetRedactedIndicesArray returns all indices of partitions where the bytecount is zero.
func (PartitionedData) Hash ¶
func (c PartitionedData) Hash() []byte
Hash returns the SHA256 of the whole partitioned data.
func (PartitionedData) Marshal ¶
func (c PartitionedData) Marshal() (string, error)
Marshal creates a JSON/base64 encoded representation of the partitioned data.
func (PartitionedData) Redact ¶
func (c PartitionedData) Redact(redacted_indices []int) (*PartitionedData, error)
Redact creates a copy of the data where the indices in redacted_indices are redacted.
func (PartitionedData) ToByteArray ¶
func (c PartitionedData) ToByteArray() []byte
ToByteArray returns a one-dimensional slice of all partitions.
func (PartitionedData) ToDataURL ¶
func (c PartitionedData) ToDataURL(chunksX int, chunksY int) (string, error)
ToDataURL converts the PartitionedData c with chunksX*chunksY image partitions into a whole base64-encoded data url.
func (PartitionedData) ToDataURLs ¶
func (c PartitionedData) ToDataURLs() []string
ToDataURLs will decode each partition as an data uri.
type RedactableSignature ¶ added in v0.2.0
type RedactableSignature interface { Sign(data *PartitionedData, private_key *crypto.PrivateKey) error Redact(redacted_indices []int, data *PartitionedData) (RedactableSignature, error) Verify(data *PartitionedData) error Marshal() (string, error) Unmarshal(input string) error }
RedactableSignature provides the interface for redactable signatures.
Sign creates the initial signature for data using the private_key. Note, that not all schemes accept any type of private key.
Redact creates a new signature, where the indices noted in redacted_indices are redacted. Note, that data of corse needs to contain the data which is beeing redacted. Note, that the new signature does not necessarily need to be new: e.g. with NaiveSignature, a redaction does not change the signature.