Documentation ¶
Index ¶
- Constants
- func BigIntFromCompact(compact uint32) *big.Int
- func BigIntFromHash(h *Hash) *big.Int
- func CompactFromBigInt(value *big.Int) uint32
- func ComputeHashBytes(b []byte) []byte
- func DecodeBytecodeId(bytecode []byte) uint32
- func DecodeECDSANameUnregistration(bytecode []byte) ([]byte, []byte, error)
- func DecodeECDSATxInBytecode(bytecode []byte) ([]byte, []byte, error)
- func Decrypt(key, text []byte) ([]byte, error)
- func Encrypt(key, text []byte) ([]byte, error)
- func GetUserSecretEntry() (string, error)
- func LoadBytesFile(path string) (*[]byte, error)
- func PrintBytes(b []byte)
- func PrivKeyFromBytes(pkbytes []byte) btcec.PrivateKey
- func SaveBytesFile(bytesfilebytes []byte, bytesfilepath string) error
- func Sign(pk *btcec.PrivateKey, msgbytes []byte) []byte
- func VerifySignature(signinghash Hash, signaturebytes []byte, pubkeycompressedbytes []byte) error
- type BufferReader
- func (br *BufferReader) EndOfBytes() bool
- func (br *BufferReader) GetBigInt() *big.Int
- func (br *BufferReader) GetBytes(length uint) []byte
- func (br *BufferReader) GetCounter() uint
- func (br *BufferReader) GetError() error
- func (br *BufferReader) GetExtrabytes() []byte
- func (br *BufferReader) GetHash() Hash
- func (br *BufferReader) GetUint16() uint16
- func (br *BufferReader) GetUint32() uint32
- func (br *BufferReader) GetUint64() uint64
- func (br *BufferReader) GetUint8() uint8
- func (br *BufferReader) GetVarUint() uint64
- type BufferWriter
- func (bw *BufferWriter) GetContent() []byte
- func (bw *BufferWriter) PutBigInt(i *big.Int)
- func (bw *BufferWriter) PutBytes(buf []byte)
- func (bw *BufferWriter) PutHash(h Hash)
- func (bw *BufferWriter) PutRegistredNameKey(name []byte)
- func (bw *BufferWriter) PutUint16(i uint16)
- func (bw *BufferWriter) PutUint32(i uint32)
- func (bw *BufferWriter) PutUint64(i uint64)
- func (bw *BufferWriter) PutUint8(i uint8)
- func (bw *BufferWriter) PutVarUint(i uint64)
- type ChunkStorage
- type Hash
- func ComputeHash(b []byte) Hash
- func ComputeHashTreeBranche(left *Hash, right *Hash) *Hash
- func ComputeRoot(hashes *[]Hash) Hash
- func DecodeECDSANameRegistration(bytecode []byte) (*Hash, []byte, []byte, []byte, error)
- func DecodeECDSATxOutBytecode(bytecode []byte) (*Hash, []byte, error)
- func NewHash(bytes []byte) *Hash
- type Transaction
- type TxIn
- type TxOut
Constants ¶
View Source
const ( CommKeyIdentifierUndefined = 0 CommKeyIdentifierRSAOAEP = 1 )
)
View Source
const ( ModuleIdentifierECDSATxOut = 1 ModuleIdentifierECDSATxIn = 2 ModuleIdentifierECDSANameRegistration = 3 ModuleIdentifierECDSANameUnregistration = 4 ModuleIdentifierECDSARegistredNameCommit = 5 )
)
View Source
const ChunkFileMaxSize = 20 * 1024 * 1024 //100*1024*1024
View Source
const ExtrabytesMaxSize = 100
View Source
const HashSize = 32
View Source
const RegistredNameMaxSize = 10
Variables ¶
This section is empty.
Functions ¶
func BigIntFromCompact ¶
func BigIntFromHash ¶
func CorrectTargetBigInt(targetbigint *big.Int,timestamp int64,prevtimestamp int64) *big.Int{
obstructioncoeff:=(timestamp-prevtimestamp)/(60*600)//OBSTRUCTED_MINING_TIME// about ten hours if obstructioncoeff==0 { //obstructioncoeff=1 return targetbigint } obstructioncoeffbigint:=big.NewInt(obstructioncoeff) targetbigint.Mul(targetbigint,obstructioncoeffbigint) return targetbigint }
func CompactFromBigInt ¶
func ComputeHashBytes ¶
func DecodeBytecodeId ¶
func DecodeECDSANameUnregistration ¶
func DecodeECDSANamePublicPost(bytecode []byte) ([]byte,*Extradata,error){ tmpbr:=NewBufferReader(bytecode) primitivemoduleid:=tmpbr.GetUint32() if primitivemoduleid != ModuleIdentifierECDSANamePublicPost{ return nil,nil,fmt.Errorf("Not an ECDSA Name Unregistration") } pubkeycompressedlen:=tmpbr.GetVarUint() pubkeycompressed:=tmpbr.GetBytes(uint(pubkeycompressedlen)) ed:=tmpbr.GetExtradata() tmpbrerr:=tmpbr.GetError() if tmpbrerr!=nil{ return nil,nil,tmpbrerr } if !tmpbr.EndOfBytes(){ return nil,nil,fmt.Errorf("End of bytes not reached") } return pubkeycompressed,ed,nil }
func DecodeECDSATxInBytecode ¶
func GetUserSecretEntry ¶ added in v0.2.4
func main() { fmt.Print("Enter Password: ") password, _ := GetUserSecretEntry() fmt.Printf(" Password: %s\n", password) }
go get golang.org/x/term
func LoadBytesFile ¶
func PrintBytes ¶
func PrintBytes(b []byte)
func PrivKeyFromBytes ¶
func PrivKeyFromBytes(pkbytes []byte) btcec.PrivateKey
func SaveBytesFile ¶
Types ¶
type BufferReader ¶
type BufferReader struct {
// contains filtered or unexported fields
}
func NewBufferReader ¶
func NewBufferReader(content []byte) *BufferReader
func (*BufferReader) EndOfBytes ¶
func (br *BufferReader) EndOfBytes() bool
func (*BufferReader) GetBigInt ¶
func (br *BufferReader) GetBigInt() *big.Int
func (*BufferReader) GetBytes ¶
func (br *BufferReader) GetBytes(length uint) []byte
func (*BufferReader) GetCounter ¶
func (br *BufferReader) GetCounter() uint
func (*BufferReader) GetError ¶
func (br *BufferReader) GetError() error
func (*BufferReader) GetExtrabytes ¶
func (br *BufferReader) GetExtrabytes() []byte
func (*BufferReader) GetHash ¶
func (br *BufferReader) GetHash() Hash
func (*BufferReader) GetUint16 ¶
func (br *BufferReader) GetUint16() uint16
func (*BufferReader) GetUint32 ¶
func (br *BufferReader) GetUint32() uint32
func (*BufferReader) GetUint64 ¶
func (br *BufferReader) GetUint64() uint64
func (*BufferReader) GetUint8 ¶
func (br *BufferReader) GetUint8() uint8
func (*BufferReader) GetVarUint ¶
func (br *BufferReader) GetVarUint() uint64
type BufferWriter ¶
type BufferWriter struct {
// contains filtered or unexported fields
}
func NewBufferWriter ¶
func NewBufferWriter() *BufferWriter
func (*BufferWriter) GetContent ¶
func (bw *BufferWriter) GetContent() []byte
func (*BufferWriter) PutBigInt ¶
func (bw *BufferWriter) PutBigInt(i *big.Int)
func (*BufferWriter) PutBytes ¶
func (bw *BufferWriter) PutBytes(buf []byte)
func (*BufferWriter) PutHash ¶
func (bw *BufferWriter) PutHash(h Hash)
func (*BufferWriter) PutRegistredNameKey ¶
func (bw *BufferWriter) PutRegistredNameKey(name []byte)
func (*BufferWriter) PutUint16 ¶
func (bw *BufferWriter) PutUint16(i uint16)
func (*BufferWriter) PutUint32 ¶
func (bw *BufferWriter) PutUint32(i uint32)
func (*BufferWriter) PutUint64 ¶
func (bw *BufferWriter) PutUint64(i uint64)
func (*BufferWriter) PutUint8 ¶
func (bw *BufferWriter) PutUint8(i uint8)
func (*BufferWriter) PutVarUint ¶
func (bw *BufferWriter) PutVarUint(i uint64)
type ChunkStorage ¶
type ChunkStorage struct { Path string // Chunkposition []int64 Chunksize []int64 Chunkfileid []int // contains filtered or unexported fields }
ChunkStorage is
func (*ChunkStorage) AddChunk ¶
func (cs *ChunkStorage) AddChunk(data []byte) error
func (*ChunkStorage) GetChunk ¶
func (cs *ChunkStorage) GetChunk(position int64, length int64, fileid int) []byte
func (*ChunkStorage) GetChunkById ¶
func (cs *ChunkStorage) GetChunkById(chunkid int) []byte
func (*ChunkStorage) NbChunks ¶
func (cs *ChunkStorage) NbChunks() int
type Hash ¶
func ComputeHash ¶
func ComputeHashTreeBranche ¶
func ComputeRoot ¶
type Transaction ¶
func NewRewardTransaction ¶
func NewRewardTransaction(Value uint64, Fee uint64, Pubkeyhash Hash) *Transaction
func UnserializeTransaction ¶
func UnserializeTransaction(bytes []byte) (*Transaction, error)
func (*Transaction) ComputeHash ¶
func (tx *Transaction) ComputeHash() Hash
func (*Transaction) ComputeSigningHash ¶
func (tx *Transaction) ComputeSigningHash() (Hash, error)
func (*Transaction) JSONSerialize ¶
func (tx *Transaction) JSONSerialize() []byte
func (*Transaction) Serialize ¶
func (tx *Transaction) Serialize() []byte
type TxOut ¶
func NewECDSATxOut ¶
func (*TxOut) CompareWithAddress ¶
func NewECDSAEngagementRewardClaim(engagementtxhash Hash,engagementtxindex uint32,pubkeycompressedbytes []byte) TxIn{ var tmptxin TxIn tmptxin.Hash=engagementtxhash tmptxin.Index=engagementtxindex tmpbw:=NewBufferWriter() tmpbw.PutUint32(ModuleIdentifierECDSAEngagementPublicPostRewardClaim)// tmpbw.PutVarUint(uint64(len(pubkeycompressedbytes))) tmpbw.PutBytes(pubkeycompressedbytes) tmpbw.PutVarUint(uint64 (0)) //no extradata tmptxin.Bytecode=append(tmptxin.Bytecode,tmpbw.GetContent()...) return tmptxin }
func NewECDSAEngagementPublicPost(eid uint32,stakedamount uint64,txhash Hash,index uint32,claimaddress Hash) TxOut{ var tmptxout TxOut tmptxout.Value=stakedamount tmpbw:=NewBufferWriter() tmpbw.PutUint32(ModuleIdentifierECDSAEngagementPublicPost)// tmpbw.PutUint32(eid)//EngagementIdentifierLikePublicPost or EngagementIdentifierDislikePublicPost //tmpbw.PutVarUint(uint64(len(name))) tmpbw.PutHash(txhash) tmpbw.PutUint32(index) tmpbw.PutHash(claimaddress) tmpbw.PutVarUint(0)// No extradata tmptxout.Bytecode=tmpbw.GetContent() return tmptxout }
func (*TxOut) GetAssetState ¶
Click to show internal directories.
Click to hide internal directories.