Documentation
¶
Overview ¶
license: https://mit-license.org * ============================================================================== * 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 * * DIMP : Decentralized Instant Messaging Protocol * * Written in 2026 by Moky <albert.moky@gmail.com> * * ============================================================================== * The MIT License (MIT) * * Copyright (c) 2026 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 * ============================================================================== * 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 * ============================================================================== * 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 * ============================================================================== * 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 * ============================================================================== * 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 * ============================================================================== * 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. * ==============================================================================
Index ¶
- func GetKeyAlgorithm(key StringKeyMap) string
- func MatchEncryptKey(pKey EncryptKey, sKey DecryptKey) bool
- func MatchSignKey(sKey SignKey, pKey VerifyKey) bool
- func NewAESKey() SymmetricKey
- func NewAESKeyWithMap(dict StringKeyMap) SymmetricKey
- func NewECCPrivateKey() PrivateKey
- func NewECCPrivateKeyWithMap(dict StringKeyMap) PrivateKey
- func NewECCPublicKeyWithMap(dict StringKeyMap) PublicKey
- func NewPlainKey() SymmetricKey
- func NewPlainKeyWithMap(dict StringKeyMap) SymmetricKey
- type AESKey
- func (key *AESKey) Algorithm() string
- func (key *AESKey) Data() TransportableData
- func (key *AESKey) Decrypt(ciphertext []byte, params StringKeyMap) []byte
- func (key *AESKey) Encrypt(plaintext []byte, extra StringKeyMap) []byte
- func (key *AESKey) Equal(other any) bool
- func (key *AESKey) MatchEncryptKey(pKey EncryptKey) bool
- type ECCPrivateKey
- type ECCPublicKey
- type IRSAPrivateKey
- type IRSAPublicKey
- type PlainKey
- func (key *PlainKey) Algorithm() string
- func (key *PlainKey) Data() TransportableData
- func (key *PlainKey) Decrypt(ciphertext []byte, _ StringKeyMap) []byte
- func (key *PlainKey) Encrypt(plaintext []byte, _ StringKeyMap) []byte
- func (key *PlainKey) Equal(other any) bool
- func (key *PlainKey) MatchEncryptKey(pKey EncryptKey) bool
- type RSAPrivateKey
- func (key *RSAPrivateKey) Algorithm() string
- func (key *RSAPrivateKey) Data() TransportableData
- func (key *RSAPrivateKey) Decrypt(ciphertext []byte, _ StringKeyMap) []byte
- func (key *RSAPrivateKey) Equal(other any) bool
- func (key *RSAPrivateKey) MatchEncryptKey(pKey EncryptKey) bool
- func (key *RSAPrivateKey) PublicKey() PublicKey
- func (key *RSAPrivateKey) Sign(data []byte) []byte
- type RSAPublicKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetKeyAlgorithm ¶
func GetKeyAlgorithm(key StringKeyMap) string
func MatchEncryptKey ¶
func MatchEncryptKey(pKey EncryptKey, sKey DecryptKey) bool
func MatchSignKey ¶
func MatchSignKey(sKey SignKey, pKey VerifyKey) bool
func NewAESKeyWithMap ¶
func NewAESKeyWithMap(dict StringKeyMap) SymmetricKey
func NewECCPrivateKeyWithMap ¶
func NewECCPrivateKeyWithMap(dict StringKeyMap) PrivateKey
func NewECCPublicKeyWithMap ¶
func NewECCPublicKeyWithMap(dict StringKeyMap) PublicKey
func NewPlainKey ¶
func NewPlainKey() SymmetricKey
func NewPlainKeyWithMap ¶
func NewPlainKeyWithMap(dict StringKeyMap) SymmetricKey
Types ¶
type AESKey ¶
type AESKey struct {
//SymmetricKey
*Dictionary
// contains filtered or unexported fields
}
AESKey implements the SymmetricKey interface for AES encryption/decryption
Standard symmetric key for secure message encryption with configurable key sizes (typically 32 bytes for AES-256)
KeyInfo JSON Format: {
"algorithm" : "AES",
"keySize" : 32, // Optional: Key size in bytes (16=AES-128, 24=AES-192, 32=AES-256)
"data" : "{BASE64}" // Base64-encoded raw key material
}
type ECCPrivateKey ¶
type ECCPrivateKey struct {
//PrivateKey
*Dictionary
// contains filtered or unexported fields
}
ECCPrivateKey implements the PrivateKey interface for ECC (Elliptic Curve Cryptography)
Uses secp256k1 curve (Bitcoin/Ethereum standard) for asymmetric cryptography
KeyInfo JSON Format: {
"algorithm" : "ECC",
"curve" : "secp256k1", // Elliptic curve identifier (secp256k1 is primary supported curve)
"data" : "{BASE64}" // Base64-encoded raw ECC private key material
}
type ECCPublicKey ¶
type ECCPublicKey struct {
//PublicKey
*Dictionary
// contains filtered or unexported fields
}
ECCPublicKey implements the PublicKey interface for ECC (Elliptic Curve Cryptography)
Corresponding public key for ECCPrivateKey, uses secp256k1 curve
KeyInfo JSON Format: {
"algorithm": "ECC",
"curve": "secp256k1", // Elliptic curve identifier (matches private key curve)
"data": "{BASE64}" // Base64-encoded raw ECC public key material
}
func (*ECCPublicKey) MatchSignKey ¶
func (key *ECCPublicKey) MatchSignKey(sKey SignKey) bool
Override
type IRSAPrivateKey ¶
type IRSAPrivateKey interface {
PrivateKey
DecryptKey
}
func NewRSAPrivateKeyWithMap ¶
func NewRSAPrivateKeyWithMap(dict StringKeyMap) IRSAPrivateKey
type IRSAPublicKey ¶
type IRSAPublicKey interface {
PublicKey
EncryptKey
}
func NewRSAPublicKeyWithMap ¶
func NewRSAPublicKeyWithMap(dict StringKeyMap) IRSAPublicKey
type PlainKey ¶
type PlainKey struct {
//SymmetricKey
*Dictionary
// contains filtered or unexported fields
}
PlainKey implements the SymmetricKey interface for unencrypted/broadcast messages
"Null" symmetric key that performs no actual encryption/decryption on message data
Designed for broadcast messages where content should remain in plaintext
func (*PlainKey) MatchEncryptKey ¶
Override
type RSAPrivateKey ¶
type RSAPrivateKey struct {
//IRSAPrivateKey
*Dictionary
// contains filtered or unexported fields
}
RSAPrivateKey implements the IRSAPrivateKey interface for RSA asymmetric cryptography
Provides RSA private key capabilities (signing, decryption, key pair management)
KeyInfo JSON Format: {
"algorithm": "RSA",
"data": "{BASE64}" // Base64-encoded raw RSA private key material (PKCS#8 format)
}
func (*RSAPrivateKey) Decrypt ¶
func (key *RSAPrivateKey) Decrypt(ciphertext []byte, _ StringKeyMap) []byte
Override
func (*RSAPrivateKey) MatchEncryptKey ¶
func (key *RSAPrivateKey) MatchEncryptKey(pKey EncryptKey) bool
Override
type RSAPublicKey ¶
type RSAPublicKey struct {
//PublicKey, EncryptKey
*Dictionary
// contains filtered or unexported fields
}
RSAPublicKey implements the PublicKey and EncryptKey interfaces for RSA cryptography
Corresponding public key for RSAPrivateKey (encryption, signature verification)
KeyInfo JSON Format: {
"algorithm": "RSA",
"data": "{BASE64}" // Base64-encoded raw RSA public key material (PKCS#1 format)
}
func (*RSAPublicKey) Encrypt ¶
func (key *RSAPublicKey) Encrypt(plaintext []byte, _ StringKeyMap) []byte
Override
func (*RSAPublicKey) MatchSignKey ¶
func (key *RSAPublicKey) MatchSignKey(sKey SignKey) bool
Override
Directories
¶
| Path | Synopsis |
|---|---|
|
license: https://mit-license.org * ============================================================================== * 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.
|
license: https://mit-license.org * ============================================================================== * 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. |