2024-11-26 17:43:02 +00:00
|
|
|
|
<a id="whalesong"></a>
|
2024-08-02 04:27:56 +00:00
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
# WhaleSong
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
### *class* Cryptography.WhaleSong.Transport(cache, nodeNickname, daisyCryptography, psk)
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
2024-08-01 22:03:59 +00:00
|
|
|
|
[🔗 Source](https://git.utopic.work/PierMesh/piermesh/src/branch/main/Cryptography/WhaleSong.py)
|
|
|
|
|
|
2024-08-01 01:09:11 +00:00
|
|
|
|
#### loadedKeys
|
|
|
|
|
|
|
|
|
|
In memory representations of cryptography keys
|
|
|
|
|
|
|
|
|
|
* **Type:**
|
|
|
|
|
dict
|
|
|
|
|
|
|
|
|
|
#### nodeNickname
|
|
|
|
|
|
|
|
|
|
Name of node for isolating configs when running multiple nodes
|
|
|
|
|
|
|
|
|
|
* **Type:**
|
|
|
|
|
str
|
|
|
|
|
|
|
|
|
|
#### cache
|
|
|
|
|
|
|
|
|
|
Daisy cache for use in storing cryptography information
|
|
|
|
|
|
|
|
|
|
* **Type:**
|
2024-11-26 17:43:02 +00:00
|
|
|
|
[Daisy.Cache.Cache](/PierMesh/piermesh/src/branch/main/docs/Daisy/Cache.md#Daisy.Cache.Cache)
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
|
|
|
|
#### publicKey
|
|
|
|
|
|
|
|
|
|
Public key for node
|
|
|
|
|
|
|
|
|
|
#### privateKey
|
|
|
|
|
|
|
|
|
|
Private key for node
|
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
#### daisyCryptography
|
|
|
|
|
|
|
|
|
|
Record cryptography reference
|
|
|
|
|
|
|
|
|
|
* **Type:**
|
|
|
|
|
[Daisy.CryptographyUtil.SteelPetal](/PierMesh/piermesh/src/branch/main/docs/Daisy/CryptographyUtil.md#Daisy.CryptographyUtil.SteelPetal)
|
|
|
|
|
|
|
|
|
|
#### addPeerEphemeralKey(onodeID, peerEphemeralKey: bytes)
|
|
|
|
|
|
|
|
|
|
Add a peer node’s epehemeral key for session encryption
|
|
|
|
|
|
|
|
|
|
onodeID
|
|
|
|
|
: Node identifier
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
peerEphemeralKey: bytes
|
|
|
|
|
: Serialized ephemeral key
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
#### addPublickey(onodeID, publicKey, forSelf: bool = False)
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
Add a public key for a given node including this one
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
onodeID
|
|
|
|
|
: Node identifier
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
publicKey
|
|
|
|
|
: Public key to add
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
forSelf: bool
|
|
|
|
|
: Whether to add key for this node
|
|
|
|
|
|
|
|
|
|
#### decrypt(data, onodeID: str, nonce, tag)
|
|
|
|
|
|
|
|
|
|
Decrypt bytes and return either str or dict depending on result
|
|
|
|
|
|
|
|
|
|
onodeID: str
|
|
|
|
|
: Node identifier
|
|
|
|
|
|
|
|
|
|
nonce
|
|
|
|
|
: Encryption nonce
|
|
|
|
|
|
|
|
|
|
tag
|
|
|
|
|
: Encryption tag
|
|
|
|
|
|
|
|
|
|
#### encrypt(data, nodeID: str, isDict: bool = True, pskEncrypt=False)
|
|
|
|
|
|
|
|
|
|
Encrypt given data with AES GCM
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
|
|
|
|
data
|
|
|
|
|
: Either bytes or dict to encrypt
|
|
|
|
|
|
|
|
|
|
isDict: bool
|
|
|
|
|
: Whether data is a dictionary
|
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
pskEncrypt: bool
|
|
|
|
|
: Whether to encrypt with pre-shared key
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
#### genOurEphemeralKey(onodeID)
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
Generate epehemeral key for session encryption with given node
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
#### genStaticKey(onodeID)
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
Generate static key for session encryption with given node
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
#### generateSessionKey(onodeID)
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
Generate session key for transport encryption
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
onodeID
|
|
|
|
|
: Node identifier
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
#### getRecord(store: str, key: str, ephemeral=False)
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
|
|
|
|
Get record from store: store with key: key
|
|
|
|
|
|
|
|
|
|
#### initStore(store: str)
|
|
|
|
|
|
|
|
|
|
Initialize store: store
|
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
#### kdf(bytesX)
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
Key derivation function
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
#### sessionSetup(onodeID, peerEphemeralKey: bytes)
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
Set up transport encryption session
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
onodeID
|
|
|
|
|
: Node identifier
|
2024-08-01 01:09:11 +00:00
|
|
|
|
|
2024-11-26 17:43:02 +00:00
|
|
|
|
peerEphemeralKey: bytes
|
|
|
|
|
: Serialized ephemeral key
|