Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AnonymousID = Principal{[]byte{0x04}}
AnonymousID is used for the anonymous caller. It can be used in call and query requests without a signature.
View Source
var (
DefaultSubAccount [32]byte
)
Functions ¶
This section is empty.
Types ¶
type AccountIdentifier ¶ added in v0.2.1
type AccountIdentifier [28]byte
func (AccountIdentifier) String ¶ added in v0.2.1
func (id AccountIdentifier) String() string
type Principal ¶
type Principal struct {
Raw []byte
}
Principal are generic identifiers for canisters, users and possibly other concepts in the future.
Example ¶
package main
import (
"encoding/hex"
"fmt"
"github.com/aviate-labs/principal-go"
)
func main() {
raw, _ := hex.DecodeString("abcd01")
p := principal.Principal{raw}
fmt.Println(p.Encode())
}
Output: em77e-bvlzu-aq
func Decode ¶
Decode converts a textual representation into a principal.
Example ¶
package main
import (
"fmt"
"github.com/aviate-labs/principal-go"
)
func main() {
p, _ := principal.Decode("em77e-bvlzu-aq")
fmt.Printf("%x", p.Raw)
}
Output: abcd01
func NewSelfAuthenticating ¶
NewSelfAuthenticating returns a self authenticating principal identifier based on the given public key.
func (Principal) AccountIdentifier ¶ added in v0.2.1
func (p Principal) AccountIdentifier(subAccount [32]byte) AccountIdentifier
Returns the account identifier corresponding with the given sub-account.
type SubAccount ¶ added in v0.2.1
type SubAccount [32]byte
Click to show internal directories.
Click to hide internal directories.