Documentation ¶
Overview ¶
license: https://mit-license.org * * Ming-Ke-Ming : Decentralized User Identity Authentication * * Written in 2020 by Moky <albert.moky@gmail.com> * * ============================================================================== * The MIT License (MIT) * * Copyright (c) 2020 Albert Moky * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * ==============================================================================
license: https://mit-license.org * * Ming-Ke-Ming : Decentralized User Identity Authentication * * Written in 2021 by Moky <albert.moky@gmail.com> * * ============================================================================== * The MIT License (MIT) * * Copyright (c) 2021 Albert Moky * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * ==============================================================================
license: https://mit-license.org * * Ming-Ke-Ming : Decentralized User Identity Authentication * * Written in 2021 by Moky <albert.moky@gmail.com> * * ============================================================================== * The MIT License (MIT) * * Copyright (c) 2021 Albert Moky * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * ==============================================================================
license: https://mit-license.org * * Ming-Ke-Ming : Decentralized User Identity Authentication * * Written in 2021 by Moky <albert.moky@gmail.com> * * ============================================================================== * The MIT License (MIT) * * Copyright (c) 2021 Albert Moky * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * ==============================================================================
Index ¶
- func BTCAddressGenerate(fingerprint []byte, network NetworkType) Address
- func BTCAddressParse(base58 string) Address
- func ETHAddressGenerate(fingerprint []byte) Address
- func ETHAddressParse(address string) Address
- func GetValidateETHAddressString(address string) string
- func IsValidateETHAddressString(address string) bool
- func NewBTCAddress(address string, network NetworkType) Address
- func NewBTCMeta(version MetaType, key VerifyKey, seed string, fingerprint []byte) Meta
- func NewBulletin(identifier ID, data string, signature string) Bulletin
- func NewDefaultMeta(key VerifyKey, seed string, fingerprint []byte) Meta
- func NewDocument(identifier ID, data string, signature string) Document
- func NewETHAddress(address string) Address
- func NewETHMeta(version MetaType, key VerifyKey, seed string, fingerprint []byte) Meta
- func NewGeneralDocumentFactory(docType string) DocumentFactory
- func NewGeneralMetaFactory(version MetaType) MetaFactory
- func NewVisa(identifier ID, data string, signature string) Visa
- func ParseBTCMeta(dict map[string]interface{}) Meta
- func ParseBulletin(dict map[string]interface{}) Bulletin
- func ParseDefaultMeta(dict map[string]interface{}) Meta
- func ParseDocument(dict map[string]interface{}) Document
- func ParseETHMeta(dict map[string]interface{}) Meta
- func ParseVisa(dict map[string]interface{}) Visa
- type BTCAddress
- type BTCMeta
- type DefaultMeta
- type ETHAddress
- type ETHMeta
- type GeneralDocumentFactory
- type GeneralMetaFactory
- func (factory *GeneralMetaFactory) CreateMeta(key VerifyKey, seed string, fingerprint []byte) Meta
- func (factory *GeneralMetaFactory) GenerateMeta(sKey SignKey, seed string) Meta
- func (factory *GeneralMetaFactory) Init(version MetaType) MetaFactory
- func (factory *GeneralMetaFactory) ParseMeta(meta map[string]interface{}) Meta
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BTCAddressGenerate ¶
func BTCAddressGenerate(fingerprint []byte, network NetworkType) Address
*
- Generate address with fingerprint and network ID *
- @param fingerprint = meta.fingerprint or key.data
- @param network - address type
- @return Address object
func BTCAddressParse ¶
func BTCAddressParse(base58 string) Address
*
- Parse a string for BTC address *
- @param base58 - address string
- @return null on error
func ETHAddressGenerate ¶
func ETHAddressGenerate(fingerprint []byte) Address
*
- Generate ETH address with key.data *
- @param fingerprint = key.data
- @return Address object
func ETHAddressParse ¶
func ETHAddressParse(address string) Address
*
- Parse a string for ETH address *
- @param address - address string
- @return null on error
func NewBTCAddress ¶
func NewBTCAddress(address string, network NetworkType) Address
func NewBTCMeta ¶
func NewBulletin ¶
func NewDefaultMeta ¶
func NewDocument ¶
func NewETHAddress ¶
func NewETHAddress(address string) Address
func NewETHMeta ¶
func NewGeneralDocumentFactory ¶
func NewGeneralDocumentFactory(docType string) DocumentFactory
func NewGeneralMetaFactory ¶
func NewGeneralMetaFactory(version MetaType) MetaFactory
func ParseBTCMeta ¶
func ParseBTCMeta(dict map[string]interface{}) Meta
func ParseBulletin ¶
func ParseBulletin(dict map[string]interface{}) Bulletin
func ParseDefaultMeta ¶
func ParseDefaultMeta(dict map[string]interface{}) Meta
func ParseDocument ¶
func ParseDocument(dict map[string]interface{}) Document
func ParseETHMeta ¶
func ParseETHMeta(dict map[string]interface{}) Meta
Types ¶
type BTCAddress ¶
type BTCAddress struct { ConstantString // contains filtered or unexported fields }
*
- Address like BitCoin *
- data format: "network+digest+code"
- network -- 1 byte
- digest -- 20 bytes
- code -- 4 bytes *
- algorithm:
- fingerprint = sign(seed, SK);
- digest = ripemd160(sha256(fingerprint));
- code = sha256(sha256(network + digest)).prefix(4);
- address = base58_encode(network + digest + code);
func (*BTCAddress) Init ¶
func (address *BTCAddress) Init(string string, network NetworkType) Address
func (*BTCAddress) IsBroadcast ¶
func (address *BTCAddress) IsBroadcast() bool
func (*BTCAddress) IsGroup ¶
func (address *BTCAddress) IsGroup() bool
func (*BTCAddress) IsUser ¶
func (address *BTCAddress) IsUser() bool
func (*BTCAddress) Network ¶
func (address *BTCAddress) Network() NetworkType
type BTCMeta ¶
type BTCMeta struct { BaseMeta // contains filtered or unexported fields }
*
- Meta to build BTC address for ID *
- version:
- 0x02 - BTC
- 0x03 - ExBTC *
- algorithm:
- CT = key.data;
- hash = ripemd160(sha256(CT));
- code = sha256(sha256(network + hash)).prefix(4);
- address = base58_encode(network + hash + code);
func (*BTCMeta) GenerateAddress ¶
func (meta *BTCMeta) GenerateAddress(network NetworkType) Address
func (*BTCMeta) InitWithType ¶
type DefaultMeta ¶
type DefaultMeta struct { BaseMeta // contains filtered or unexported fields }
*
- Default Meta to build ID with 'name@address' *
- version:
- 0x01 - MKM *
- algorithm:
- CT = fingerprint = sKey.sign(seed);
- hash = ripemd160(sha256(CT));
- code = sha256(sha256(network + hash)).prefix(4);
- address = base58_encode(network + hash + code);
func (*DefaultMeta) GenerateAddress ¶
func (meta *DefaultMeta) GenerateAddress(network NetworkType) Address
func (*DefaultMeta) Init ¶
func (meta *DefaultMeta) Init(dict map[string]interface{}) Meta
func (*DefaultMeta) InitWithType ¶
func (meta *DefaultMeta) InitWithType(version MetaType, key VerifyKey, seed string, fingerprint []byte) Meta
type ETHAddress ¶
type ETHAddress struct {
ConstantString
}
*
- Address like Ethereum *
- data format: "0x{address}" *
- algorithm:
- fingerprint = PK.data;
- digest = keccak256(fingerprint);
- address = hex_encode(digest.suffix(20));
func (*ETHAddress) IsBroadcast ¶
func (address *ETHAddress) IsBroadcast() bool
func (*ETHAddress) IsGroup ¶
func (address *ETHAddress) IsGroup() bool
func (*ETHAddress) IsUser ¶
func (address *ETHAddress) IsUser() bool
func (*ETHAddress) Network ¶
func (address *ETHAddress) Network() NetworkType
type ETHMeta ¶
type ETHMeta struct { BaseMeta // contains filtered or unexported fields }
*
- Meta to build ETH address for ID *
- version:
- 0x04 - ETH
- 0x05 - ExETH *
- algorithm:
- CT = key.data; // without prefix byte
- digest = keccak256(CT);
- address = hex_encode(digest.suffix(20));
func (*ETHMeta) GenerateAddress ¶
func (meta *ETHMeta) GenerateAddress(network NetworkType) Address
func (*ETHMeta) InitWithType ¶
type GeneralDocumentFactory ¶
type GeneralDocumentFactory struct {
// contains filtered or unexported fields
}
*
- Document Factory
- ~~~~~~~~~~~~~~~~
func (*GeneralDocumentFactory) CreateDocument ¶
func (factory *GeneralDocumentFactory) CreateDocument(identifier ID, data string, signature string) Document
func (*GeneralDocumentFactory) Init ¶
func (factory *GeneralDocumentFactory) Init(docType string) DocumentFactory
func (*GeneralDocumentFactory) ParseDocument ¶
func (factory *GeneralDocumentFactory) ParseDocument(doc map[string]interface{}) Document
type GeneralMetaFactory ¶
type GeneralMetaFactory struct {
// contains filtered or unexported fields
}
*
- Meta Factory
- ~~~~~~~~~~~~
func (*GeneralMetaFactory) CreateMeta ¶
func (factory *GeneralMetaFactory) CreateMeta(key VerifyKey, seed string, fingerprint []byte) Meta
func (*GeneralMetaFactory) GenerateMeta ¶
func (factory *GeneralMetaFactory) GenerateMeta(sKey SignKey, seed string) Meta
func (*GeneralMetaFactory) Init ¶
func (factory *GeneralMetaFactory) Init(version MetaType) MetaFactory
func (*GeneralMetaFactory) ParseMeta ¶
func (factory *GeneralMetaFactory) ParseMeta(meta map[string]interface{}) Meta