-
Hans Moog authored
* Refactor: cleaned up unused files * Refactor: changing branches (need to commit) * Refactor: refactored some code * Feat: finished signature scheme for value transactions * Fix: fix broken merge * Refactor: refactored some code * Refactor: refactored transaction marshaling and unmarshaling * Fix: fixed missing err check * Feat: added payload string method * Feat: added Bytes() method to transactionid * Feat: refactored the marshaling * Refactor: refactored serialization code * Feat: started implementing the payload metadata * Docs: added some doc comments * Docs: added some additional docs * Feat: added a CachedObject of the payloadmetadata + added comments * Feat: updated hive.go + added further models * Feat: pc died - rescued files from disk * Feat: further models implemented * Feat: added missing model for value tangle * Feat: started writing test cases for value tangle * Feat: started to adjust marshaling of transaction * Feat: refactored marshaling of payload * Feat: intermediary commit before bigger refactor * Feat: removed identity package * Fix: fixed bugs due to refactor * Fix: fixed further bugs * Fix: fixed further bugs * Fix: hopefully last bugs :p * Feat: changed time marshal to use nanoseconds * Fix: fixed time marshaling * Fix: fixed serialization bug * Docs: added a comment to handling the zero value * Refactor: refactored transaction to separate issuerKey * Feat: added a parse method for Signatures * Feat: updated to latest hive.go
Hans Moog authored* Refactor: cleaned up unused files * Refactor: changing branches (need to commit) * Refactor: refactored some code * Feat: finished signature scheme for value transactions * Fix: fix broken merge * Refactor: refactored some code * Refactor: refactored transaction marshaling and unmarshaling * Fix: fixed missing err check * Feat: added payload string method * Feat: added Bytes() method to transactionid * Feat: refactored the marshaling * Refactor: refactored serialization code * Feat: started implementing the payload metadata * Docs: added some doc comments * Docs: added some additional docs * Feat: added a CachedObject of the payloadmetadata + added comments * Feat: updated hive.go + added further models * Feat: pc died - rescued files from disk * Feat: further models implemented * Feat: added missing model for value tangle * Feat: started writing test cases for value tangle * Feat: started to adjust marshaling of transaction * Feat: refactored marshaling of payload * Feat: intermediary commit before bigger refactor * Feat: removed identity package * Fix: fixed bugs due to refactor * Fix: fixed further bugs * Fix: fixed further bugs * Fix: hopefully last bugs :p * Feat: changed time marshal to use nanoseconds * Fix: fixed time marshaling * Fix: fixed serialization bug * Docs: added a comment to handling the zero value * Refactor: refactored transaction to separate issuerKey * Feat: added a parse method for Signatures * Feat: updated to latest hive.go
public_key.go 1.10 KiB
package ed25119
import (
"errors"
"fmt"
"github.com/oasislabs/ed25519"
"github.com/iotaledger/goshimmer/packages/binary/marshalutil"
)
type PublicKey [PublicKeySize]byte
func PublicKeyFromBytes(bytes []byte) (result PublicKey, err error, consumedBytes int) {
if len(bytes) < PublicKeySize {
err = fmt.Errorf("bytes too short")
return
}
copy(result[:], bytes)
consumedBytes = PublicKeySize
return
}
func ParsePublicKey(marshalUtil *marshalutil.MarshalUtil) (PublicKey, error) {
if id, err := marshalUtil.Parse(func(data []byte) (interface{}, error, int) { return PublicKeyFromBytes(data) }); err != nil {
return PublicKey{}, err
} else {
return id.(PublicKey), nil
}
}
func (publicKey PublicKey) VerifySignature(data []byte, signature Signature) bool {
return ed25519.Verify(publicKey[:], data, signature[:])
}
func (publicKey PublicKey) Bytes() []byte {
return publicKey[:]
}
func (publicKey *PublicKey) UnmarshalBinary(bytes []byte) (err error) {
if len(bytes) < PublicKeySize {
return errors.New("not enough bytes")
}
copy(publicKey[:], bytes[:])
return
}
const PublicKeySize = 32