module arch.node.engines.encryption_config;

import prelude open;
import arch.node.engines.encryption_messages open;
import arch.node.types.engine open;
import arch.node.types.messages open;
import arch.node.types.identities open;
import arch.system.identity.identity open hiding {ExternalIdentity};

type EncryptionCfg :=
  mkEncryptionCfg@{
    encryptor
      : Set ReadsForEvidence
        -> ExternalIdentity
        -> Encryptor ByteString Backend Plaintext Ciphertext;
    backend : Backend;
    readsForEngineAddress : EngineID;
  };

module encryption_config_example;
  
  encryptionCfg : EngineCfg EncryptionCfg :=
    mkEngineCfg@{
      node := Curve25519PubKey "0xabcd1234";
      name := "encryption";
      cfg :=
        mkEncryptionCfg@{
          encryptor :=
            \{_ _ :=
              mkEncryptor@{
                encrypt := \{_ x := x};
                encryptorHash :=
                  mkHASH@{
                    ordKey :=
                      mkOrdkey@{
                        compare := Ord.cmp;
                      };
                    hash := \{x := "0x1234abcd"};
                  };
              }};
          backend := BackendLocalMemory;
          readsForEngineAddress := mkPair none "Blah";
        };
    };
end;