nim-libp2p/move-transport-interop-tests/libp2p/crypto/crypto.html

1714 lines
146 KiB
HTML

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- This file is generated by Nim. -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Favicon -->
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
<!-- Google fonts -->
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
<!-- CSS -->
<title>libp2p/crypto/crypto</title>
<link rel="stylesheet" type="text/css" href="../../nimdoc.out.css">
<script type="text/javascript" src="../../dochack.js"></script>
<script type="text/javascript">
function main() {
var pragmaDots = document.getElementsByClassName("pragmadots");
for (var i = 0; i < pragmaDots.length; i++) {
pragmaDots[i].onclick = function(event) {
// Hide tease
event.target.parentNode.style.display = "none";
// Show actual
event.target.parentNode.nextElementSibling.style.display = "inline";
}
}
function switchTheme(e) {
if (e.target.checked) {
document.documentElement.setAttribute('data-theme', 'dark');
localStorage.setItem('theme', 'dark');
} else {
document.documentElement.setAttribute('data-theme', 'light');
localStorage.setItem('theme', 'light');
}
}
const toggleSwitch = document.querySelector('.theme-switch input[type="checkbox"]');
if (toggleSwitch !== null) {
toggleSwitch.addEventListener('change', switchTheme, false);
}
var currentTheme = localStorage.getItem('theme');
if (!currentTheme && window.matchMedia('(prefers-color-scheme: dark)').matches) {
currentTheme = 'dark';
}
if (currentTheme) {
document.documentElement.setAttribute('data-theme', currentTheme);
if (currentTheme === 'dark' && toggleSwitch !== null) {
toggleSwitch.checked = true;
}
}
}
window.addEventListener('DOMContentLoaded', main);
</script>
</head>
<body>
<div class="document" id="documentId">
<div class="container">
<h1 class="title">libp2p/crypto/crypto</h1>
<div class="row">
<div class="three columns">
<div class="theme-switch-wrapper">
<label class="theme-switch" for="checkbox">
<input type="checkbox" id="checkbox" />
<div class="slider round"></div>
</label>
&nbsp;&nbsp;&nbsp; <em>Dark Mode</em>
</div>
<div id="global-links">
<ul class="simple">
<li>
<a href="../../theindex.html">Index</a>
</li>
</ul>
</div>
<div id="searchInputDiv">
Search: <input type="text" id="searchInput"
onkeyup="search()" />
</div>
<div>
Group by:
<select onchange="groupBy(this.value)">
<option value="section">Section</option>
<option value="type">Type</option>
</select>
</div>
<script type="text/javascript">
function main2() {
// Create the slider
var firstSlider = document.getElementsByClassName("theme-switch-wrapper")[0];
var newSlider = document.createRange().createContextualFragment(`
<div class="theme-switch-wrapper">
<label class="theme-switch" for="internalcheckbox">
<input type="checkbox" id="internalcheckbox">
<div class="slider round"></div>
</label>
&nbsp;&nbsp;&nbsp; <em>Internal</em>
</div>
`);
var sliderInst = firstSlider.after(newSlider);
// Restore slider state from storage
var currentMode = localStorage.getItem('privateMode');
if (currentMode == "private") {
document.getElementById("internalcheckbox").checked = true;
} else {
hidePrivateProcs();
}
document.getElementById("internalcheckbox").onclick = togglePrivateProcs;
}
function hidePrivateProcs() {
var toHide = document.getElementsByClassName("tohide");
for (var i = 0; i < toHide.length; i++) {
var pragmas = toHide[i].querySelectorAll("span.Identifier");
var public = false;
for (var z = 0; z < pragmas.length; z++) {
if (pragmas[z].innerText == "public") {
public = true;
break;
}
}
if (public == false) {
toHide[i].style.display = "none";
toHide[i].classList.add("hidden");
links = document.querySelectorAll("a[href='#" + encodeURIComponent(toHide[i].id) + "']");
for (var y = 0; y < links.length; y++) {
links[y].parentNode.style.display = "none";
links[y].parentNode.classList.add("hidden");
}
}
}
// TOC
var nestedSections = document.getElementsByClassName("nested-toc-section");
for (var i = 0; i < nestedSections.length; i++) {
if (nestedSections[i].querySelectorAll("li:not(.hidden)").length == 0) {
nestedSections[i].style.display = "none";
nestedSections[i].classList.add("hidden");
}
}
var sections = document.getElementsByClassName("simple-toc-section");
for (var i = 0; i < sections.length; i++) {
if (sections[i].querySelectorAll(".nested-toc-section:not(.hidden)").length == 0) {
sections[i].parentNode.style.display = "none";
sections[i].parentNode.classList.add("hidden");
}
}
// Sections
var sections = document.getElementsByClassName("section");
for (var i = 0; i < sections.length; i++) {
if (sections[i].querySelectorAll(".item > div").length == 0) continue;
if (sections[i].querySelectorAll(".item > div:not(.hidden)").length == 0) {
sections[i].style.display = "none";
sections[i].classList.add("hidden");
}
}
}
function showPrivateProcs() {
var toHide = Array.from(document.getElementsByClassName("hidden"));
for (var i = 0; i < toHide.length; i++) {
toHide[i].style.display = "";
toHide[i].classList.remove("hidden");
}
}
function togglePrivateProcs() {
if (document.getElementById("internalcheckbox").checked) {
localStorage.setItem('privateMode', 'private');
showPrivateProcs();
} else {
localStorage.setItem('privateMode', 'public');
hidePrivateProcs();
}
}
window.addEventListener("DOMContentLoaded", main2);
</script>
<ul class="simple simple-toc" id="toc-list">
<li>
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
<ul class="simple simple-toc-section">
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#7" id="57">Types</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#CryptoError"
title="CryptoError = enum
KeyError, SigError, HashError, SchemeError">CryptoError</a></li>
<li><a class="reference" href="#CryptoResult"
title="CryptoResult[T] = Result[T, CryptoError]">CryptoResult</a></li>
<li><a class="reference" href="#DigestSheme"
title="DigestSheme = enum
Sha256, Sha512">DigestSheme</a></li>
<li><a class="reference" href="#KeyPair"
title="KeyPair = object
seckey*: PrivateKey
pubkey*: PublicKey">KeyPair</a></li>
<li><a class="reference" href="#PKScheme"
title="PKScheme = enum
RSA = 0, Ed25519, Secp256k1, ECDSA">PKScheme</a></li>
<li><a class="reference" href="#PrivateKey"
title="PrivateKey = object
case scheme*: PKScheme
of PKScheme.RSA:
when supported(PKScheme.RSA):
rsakey*: rsa.RsaPrivateKey
else:
nil
of PKScheme.Ed25519:
when supported(PKScheme.Ed25519):
edkey*: EdPrivateKey
else:
nil
of PKScheme.Secp256k1:
when supported(PKScheme.Secp256k1):
skkey*: SkPrivateKey
else:
nil
of PKScheme.ECDSA:
when supported(PKScheme.ECDSA):
eckey*: ecnist.EcPrivateKey
else:
nil">PrivateKey</a></li>
<li><a class="reference" href="#PublicKey"
title="PublicKey = object
case scheme*: PKScheme
of PKScheme.RSA:
when PKScheme.RSA in SupportedSchemes:
rsakey*: rsa.RsaPublicKey
else:
nil
of PKScheme.Ed25519:
when supported(PKScheme.Ed25519):
edkey*: EdPublicKey
else:
nil
of PKScheme.Secp256k1:
when supported(PKScheme.Secp256k1):
skkey*: SkPublicKey
else:
nil
of PKScheme.ECDSA:
when supported(PKScheme.ECDSA):
eckey*: ecnist.EcPublicKey
else:
nil">PublicKey</a></li>
<li><a class="reference" href="#Secret"
title="Secret = object
ivsize*: int
keysize*: int
macsize*: int
data*: seq[byte]">Secret</a></li>
<li><a class="reference" href="#Signature"
title="Signature = object
data*: seq[byte]">Signature</a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#10" id="60">Consts</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#libp2p_pki_schemes"
title="libp2p_pki_schemes = &quot;rsa,ed25519,secp256k1,ecnist&quot;">libp2p_pki_schemes</a></li>
<li><a class="reference" href="#RsaDefaultKeySize"
title="RsaDefaultKeySize = 3072">RsaDefaultKeySize</a></li>
<li><a class="reference" href="#SupportedSchemes"
title="SupportedSchemes = {RSA, Ed25519, Secp256k1, ECDSA}">SupportedSchemes</a></li>
<li><a class="reference" href="#SupportedSchemesInt"
title="SupportedSchemesInt = {0, 1, 2, 3}">SupportedSchemesInt</a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#12" id="62">Procs</a>
<ul class="simple simple-toc-section">
<ul class="simple nested-toc-section">$
<li><a class="reference" href="#%24"
title="`$`(key: PrivateKey | PublicKey): string">`$`(key: PrivateKey | PublicKey): string</a></li>
<li><a class="reference" href="#%24%2CSignature"
title="`$`(sig: Signature): string">`$`(sig: Signature): string</a></li>
</ul>
<ul class="simple nested-toc-section">==
<li><a class="reference" href="#%3D%3D%2CPrivateKey%2CPrivateKey"
title="`==`(key1, key2: PrivateKey): bool">`==`(key1, key2: PrivateKey): bool</a></li>
<li><a class="reference" href="#%3D%3D%2CPublicKey%2CPublicKey"
title="`==`(key1, key2: PublicKey): bool">`==`(key1, key2: PublicKey): bool</a></li>
</ul>
<ul class="simple nested-toc-section">createExchange
<li><a class="reference" href="#createExchange%2CopenArray%5Bbyte%5D%2CopenArray%5Bbyte%5D"
title="createExchange(epubkey, signature: openArray[byte]): seq[byte]">createExchange(epubkey, signature: openArray[byte]): seq[byte]</a></li>
</ul>
<ul class="simple nested-toc-section">createProposal
<li><a class="reference" href="#createProposal%2CopenArray%5Bbyte%5D%2CopenArray%5Bbyte%5D%2Cstring%2Cstring%2Cstring"
title="createProposal(nonce, pubkey: openArray[byte];
exchanges, ciphers, hashes: string): seq[byte]">createProposal(nonce, pubkey: openArray[byte];
exchanges, ciphers, hashes: string): seq[byte]</a></li>
</ul>
<ul class="simple nested-toc-section">decodeExchange
<li><a class="reference" href="#decodeExchange%2Cseq%5Bbyte%5D%2Cseq%5Bbyte%5D%2Cseq%5Bbyte%5D"
title="decodeExchange(message: seq[byte]; pubkey, signature: var seq[byte]): bool">decodeExchange(message: seq[byte]; pubkey, signature: var seq[byte]): bool</a></li>
</ul>
<ul class="simple nested-toc-section">decodeProposal
<li><a class="reference" href="#decodeProposal%2Cseq%5Bbyte%5D%2Cseq%5Bbyte%5D%2Cseq%5Bbyte%5D%2Cstring%2Cstring%2Cstring"
title="decodeProposal(message: seq[byte]; nonce, pubkey: var seq[byte];
exchanges, ciphers, hashes: var string): bool">decodeProposal(message: seq[byte]; nonce, pubkey: var seq[byte];
exchanges, ciphers, hashes: var string): bool</a></li>
</ul>
<ul class="simple nested-toc-section">getBytes
<li><a class="reference" href="#getBytes%2CPrivateKey"
title="getBytes(key: PrivateKey): CryptoResult[seq[byte]]">getBytes(key: PrivateKey): CryptoResult[seq[byte]]</a></li>
<li><a class="reference" href="#getBytes%2CPublicKey"
title="getBytes(key: PublicKey): CryptoResult[seq[byte]]">getBytes(key: PublicKey): CryptoResult[seq[byte]]</a></li>
<li><a class="reference" href="#getBytes%2CSignature"
title="getBytes(sig: Signature): seq[byte]">getBytes(sig: Signature): seq[byte]</a></li>
</ul>
<ul class="simple nested-toc-section">getField
<li><a class="reference" href="#getField%2CProtoBuffer%2Cint%2CSignature"
title="getField(pb: ProtoBuffer; field: int; value: var Signature): ProtoResult[bool]">getField(pb: ProtoBuffer; field: int; value: var Signature): ProtoResult[bool]</a></li>
<li><a class="reference" href="#getField%2CProtoBuffer%2Cint%2CT"
title="getField[T: PublicKey | PrivateKey](pb: ProtoBuffer; field: int; value: var T): ProtoResult[
bool]">getField[T: PublicKey | PrivateKey](pb: ProtoBuffer; field: int; value: var T): ProtoResult[
bool]</a></li>
</ul>
<ul class="simple nested-toc-section">getOrder
<li><a class="reference" href="#getOrder%2CopenArray%5Bbyte%5D%2CopenArray%5Bbyte%5D%2CopenArray%5Bbyte%5D%2CopenArray%5Bbyte%5D"
title="getOrder(remotePubkey, localNonce: openArray[byte];
localPubkey, remoteNonce: openArray[byte]): CryptoResult[int]">getOrder(remotePubkey, localNonce: openArray[byte];
localPubkey, remoteNonce: openArray[byte]): CryptoResult[int]</a></li>
</ul>
<ul class="simple nested-toc-section">getPublicKey
<li><a class="reference" href="#getPublicKey%2CPrivateKey"
title="getPublicKey(key: PrivateKey): CryptoResult[PublicKey]">getPublicKey(key: PrivateKey): CryptoResult[PublicKey]</a></li>
</ul>
<ul class="simple nested-toc-section">getRawBytes
<li><a class="reference" href="#getRawBytes"
title="getRawBytes(key: PrivateKey | PublicKey): CryptoResult[seq[byte]]">getRawBytes(key: PrivateKey | PublicKey): CryptoResult[seq[byte]]</a></li>
</ul>
<ul class="simple nested-toc-section">init
<li><a class="reference" href="#init%2CPrivateKey%2CopenArray%5Bbyte%5D"
title="init(key: var PrivateKey; data: openArray[byte]): bool">init(key: var PrivateKey; data: openArray[byte]): bool</a></li>
<li><a class="reference" href="#init%2CPublicKey%2CopenArray%5Bbyte%5D"
title="init(key: var PublicKey; data: openArray[byte]): bool">init(key: var PublicKey; data: openArray[byte]): bool</a></li>
<li><a class="reference" href="#init%2CSignature%2CopenArray%5Bbyte%5D"
title="init(sig: var Signature; data: openArray[byte]): bool">init(sig: var Signature; data: openArray[byte]): bool</a></li>
<li><a class="reference" href="#init%2CSignature%2Cstring"
title="init(sig: var Signature; data: string): bool">init(sig: var Signature; data: string): bool</a></li>
<li><a class="reference" href="#init%2Ctypedesc%5BPrivateKey%5D%2CopenArray%5Bbyte%5D"
title="init(t: typedesc[PrivateKey]; data: openArray[byte]): CryptoResult[PrivateKey]">init(t: typedesc[PrivateKey]; data: openArray[byte]): CryptoResult[PrivateKey]</a></li>
<li><a class="reference" href="#init%2Ctypedesc%5BPrivateKey%5D%2Cstring"
title="init(t: typedesc[PrivateKey]; data: string): CryptoResult[PrivateKey]">init(t: typedesc[PrivateKey]; data: string): CryptoResult[PrivateKey]</a></li>
<li><a class="reference" href="#init%2Ctypedesc%5BPrivateKey%5D%2C_2"
title="init(t: typedesc[PrivateKey]; key: ecnist.EcPrivateKey): PrivateKey">init(t: typedesc[PrivateKey]; key: ecnist.EcPrivateKey): PrivateKey</a></li>
<li><a class="reference" href="#init%2Ctypedesc%5BPrivateKey%5D%2CEdPrivateKey"
title="init(t: typedesc[PrivateKey]; key: EdPrivateKey): PrivateKey">init(t: typedesc[PrivateKey]; key: EdPrivateKey): PrivateKey</a></li>
<li><a class="reference" href="#init%2Ctypedesc%5BPrivateKey%5D%2C"
title="init(t: typedesc[PrivateKey]; key: rsa.RsaPrivateKey): PrivateKey">init(t: typedesc[PrivateKey]; key: rsa.RsaPrivateKey): PrivateKey</a></li>
<li><a class="reference" href="#init%2Ctypedesc%5BPrivateKey%5D%2CSkPrivateKey"
title="init(t: typedesc[PrivateKey]; key: SkPrivateKey): PrivateKey">init(t: typedesc[PrivateKey]; key: SkPrivateKey): PrivateKey</a></li>
<li><a class="reference" href="#init%2Ctypedesc%5BPublicKey%5D%2CopenArray%5Bbyte%5D"
title="init(t: typedesc[PublicKey]; data: openArray[byte]): CryptoResult[PublicKey]">init(t: typedesc[PublicKey]; data: openArray[byte]): CryptoResult[PublicKey]</a></li>
<li><a class="reference" href="#init%2Ctypedesc%5BPublicKey%5D%2Cstring"
title="init(t: typedesc[PublicKey]; data: string): CryptoResult[PublicKey]">init(t: typedesc[PublicKey]; data: string): CryptoResult[PublicKey]</a></li>
<li><a class="reference" href="#init%2Ctypedesc%5BPublicKey%5D%2C_2"
title="init(t: typedesc[PublicKey]; key: ecnist.EcPublicKey): PublicKey">init(t: typedesc[PublicKey]; key: ecnist.EcPublicKey): PublicKey</a></li>
<li><a class="reference" href="#init%2Ctypedesc%5BPublicKey%5D%2CEdPublicKey"
title="init(t: typedesc[PublicKey]; key: EdPublicKey): PublicKey">init(t: typedesc[PublicKey]; key: EdPublicKey): PublicKey</a></li>
<li><a class="reference" href="#init%2Ctypedesc%5BPublicKey%5D%2C"
title="init(t: typedesc[PublicKey]; key: rsa.RsaPublicKey): PublicKey">init(t: typedesc[PublicKey]; key: rsa.RsaPublicKey): PublicKey</a></li>
<li><a class="reference" href="#init%2Ctypedesc%5BPublicKey%5D%2CSkPublicKey"
title="init(t: typedesc[PublicKey]; key: SkPublicKey): PublicKey">init(t: typedesc[PublicKey]; key: SkPublicKey): PublicKey</a></li>
<li><a class="reference" href="#init%2Ctypedesc%5BSignature%5D%2CopenArray%5Bbyte%5D"
title="init(t: typedesc[Signature]; data: openArray[byte]): CryptoResult[Signature]">init(t: typedesc[Signature]; data: openArray[byte]): CryptoResult[Signature]</a></li>
<li><a class="reference" href="#init%2Ctypedesc%5BSignature%5D%2Cstring"
title="init(t: typedesc[Signature]; data: string): CryptoResult[Signature]">init(t: typedesc[Signature]; data: string): CryptoResult[Signature]</a></li>
<li><a class="reference" href="#init%2CT%2Cstring"
title="init[T: PrivateKey | PublicKey](key: var T; data: string): bool">init[T: PrivateKey | PublicKey](key: var T; data: string): bool</a></li>
</ul>
<ul class="simple nested-toc-section">iv
<li><a class="reference" href="#iv%2CSecret%2Cint"
title="iv(secret: Secret; id: int): seq[byte]">iv(secret: Secret; id: int): seq[byte]</a></li>
</ul>
<ul class="simple nested-toc-section">key
<li><a class="reference" href="#key%2CSecret%2Cint"
title="key(secret: Secret; id: int): seq[byte]">key(secret: Secret; id: int): seq[byte]</a></li>
</ul>
<ul class="simple nested-toc-section">mac
<li><a class="reference" href="#mac%2CSecret%2Cint"
title="mac(secret: Secret; id: int): seq[byte]">mac(secret: Secret; id: int): seq[byte]</a></li>
</ul>
<ul class="simple nested-toc-section">newRng
<li><a class="reference" href="#newRng"
title="newRng(): ref HmacDrbgContext">newRng(): ref HmacDrbgContext</a></li>
</ul>
<ul class="simple nested-toc-section">random
<li><a class="reference" href="#random%2Ctypedesc%5BKeyPair%5D%2CHmacDrbgContext"
title="random(T: typedesc[KeyPair]; rng: var HmacDrbgContext; bits = RsaDefaultKeySize): CryptoResult[
KeyPair]">random(T: typedesc[KeyPair]; rng: var HmacDrbgContext; bits = RsaDefaultKeySize): CryptoResult[
KeyPair]</a></li>
<li><a class="reference" href="#random%2Ctypedesc%5BKeyPair%5D%2CPKScheme%2CHmacDrbgContext"
title="random(T: typedesc[KeyPair]; scheme: PKScheme; rng: var HmacDrbgContext;
bits = RsaDefaultKeySize): CryptoResult[KeyPair]">random(T: typedesc[KeyPair]; scheme: PKScheme; rng: var HmacDrbgContext;
bits = RsaDefaultKeySize): CryptoResult[KeyPair]</a></li>
<li><a class="reference" href="#random%2Ctypedesc%5BPrivateKey%5D%2CHmacDrbgContext"
title="random(T: typedesc[PrivateKey]; rng: var HmacDrbgContext;
bits = RsaDefaultKeySize): CryptoResult[PrivateKey]">random(T: typedesc[PrivateKey]; rng: var HmacDrbgContext;
bits = RsaDefaultKeySize): CryptoResult[PrivateKey]</a></li>
<li><a class="reference" href="#random%2Ctypedesc%5BPrivateKey%5D%2CPKScheme%2CHmacDrbgContext"
title="random(T: typedesc[PrivateKey]; scheme: PKScheme; rng: var HmacDrbgContext;
bits = RsaDefaultKeySize): CryptoResult[PrivateKey]">random(T: typedesc[PrivateKey]; scheme: PKScheme; rng: var HmacDrbgContext;
bits = RsaDefaultKeySize): CryptoResult[PrivateKey]</a></li>
</ul>
<ul class="simple nested-toc-section">selectBest
<li><a class="reference" href="#selectBest%2Cint%2Cstring%2Cstring"
title="selectBest(order: int; p1, p2: string): string">selectBest(order: int; p1, p2: string): string</a></li>
</ul>
<ul class="simple nested-toc-section">shortLog
<li><a class="reference" href="#shortLog"
title="shortLog(key: PrivateKey | PublicKey): string">shortLog(key: PrivateKey | PublicKey): string</a></li>
</ul>
<ul class="simple nested-toc-section">shuffle
<li><a class="reference" href="#shuffle%2Cref.HmacDrbgContext%2CopenArray%5BT%5D"
title="shuffle[T](rng: ref HmacDrbgContext; x: var openArray[T])">shuffle[T](rng: ref HmacDrbgContext; x: var openArray[T])</a></li>
</ul>
<ul class="simple nested-toc-section">sign
<li><a class="reference" href="#sign%2CPrivateKey%2CopenArray%5Bbyte%5D"
title="sign(key: PrivateKey; data: openArray[byte]): CryptoResult[Signature]">sign(key: PrivateKey; data: openArray[byte]): CryptoResult[Signature]</a></li>
</ul>
<ul class="simple nested-toc-section">stretchKeys
<li><a class="reference" href="#stretchKeys%2Cstring%2Cstring%2Cseq%5Bbyte%5D"
title="stretchKeys(cipherType: string; hashType: string; sharedSecret: seq[byte]): Secret">stretchKeys(cipherType: string; hashType: string; sharedSecret: seq[byte]): Secret</a></li>
</ul>
<ul class="simple nested-toc-section">toBytes
<li><a class="reference" href="#toBytes%2CPrivateKey%2CopenArray%5Bbyte%5D"
title="toBytes(key: PrivateKey; data: var openArray[byte]): CryptoResult[int]">toBytes(key: PrivateKey; data: var openArray[byte]): CryptoResult[int]</a></li>
<li><a class="reference" href="#toBytes%2CPublicKey%2CopenArray%5Bbyte%5D"
title="toBytes(key: PublicKey; data: var openArray[byte]): CryptoResult[int]">toBytes(key: PublicKey; data: var openArray[byte]): CryptoResult[int]</a></li>
<li><a class="reference" href="#toBytes%2CSignature%2CopenArray%5Bbyte%5D"
title="toBytes(sig: Signature; data: var openArray[byte]): int">toBytes(sig: Signature; data: var openArray[byte]): int</a></li>
</ul>
<ul class="simple nested-toc-section">toRawBytes
<li><a class="reference" href="#toRawBytes%2C%2CopenArray%5Bbyte%5D"
title="toRawBytes(key: PrivateKey | PublicKey; data: var openArray[byte]): CryptoResult[
int]">toRawBytes(key: PrivateKey | PublicKey; data: var openArray[byte]): CryptoResult[
int]</a></li>
</ul>
<ul class="simple nested-toc-section">verify
<li><a class="reference" href="#verify%2CSignature%2CopenArray%5Bbyte%5D%2CPublicKey"
title="verify(sig: Signature; message: openArray[byte]; key: PublicKey): bool">verify(sig: Signature; message: openArray[byte]; key: PublicKey): bool</a></li>
</ul>
<ul class="simple nested-toc-section">write
<li><a class="reference" href="#write%2CProtoBuffer%2Cint%2CSignature"
title="write(pb: var ProtoBuffer; field: int; sig: Signature)">write(pb: var ProtoBuffer; field: int; sig: Signature)</a></li>
<li><a class="reference" href="#write%2CVBuffer%2CPublicKey"
title="write(vb: var VBuffer; pubkey: PublicKey)">write(vb: var VBuffer; pubkey: PublicKey)</a></li>
<li><a class="reference" href="#write%2CVBuffer%2CPrivateKey"
title="write(vb: var VBuffer; seckey: PrivateKey)">write(vb: var VBuffer; seckey: PrivateKey)</a></li>
<li><a class="reference" href="#write%2CVBuffer%2CPrivateKey_2"
title="write(vb: var VBuffer; sig: PrivateKey)">write(vb: var VBuffer; sig: PrivateKey)</a></li>
<li><a class="reference" href="#write%2CProtoBuffer%2Cint%2CT"
title="write[T: PublicKey | PrivateKey](pb: var ProtoBuffer; field: int; key: T)">write[T: PublicKey | PrivateKey](pb: var ProtoBuffer; field: int; key: T)</a></li>
</ul>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#18" id="68">Templates</a>
<ul class="simple simple-toc-section">
<ul class="simple nested-toc-section">goffset
<li><a class="reference" href="#goffset.t%2Cuntyped%2Cuntyped%2Cuntyped"
title="goffset(secret, id, o: untyped): untyped">goffset(secret, id, o: untyped): untyped</a></li>
</ul>
<ul class="simple nested-toc-section">ivOpenArray
<li><a class="reference" href="#ivOpenArray.t%2CSecret%2Cint"
title="ivOpenArray(secret: Secret; id: int): untyped">ivOpenArray(secret: Secret; id: int): untyped</a></li>
</ul>
<ul class="simple nested-toc-section">keyOpenArray
<li><a class="reference" href="#keyOpenArray.t%2CSecret%2Cint"
title="keyOpenArray(secret: Secret; id: int): untyped">keyOpenArray(secret: Secret; id: int): untyped</a></li>
</ul>
<ul class="simple nested-toc-section">macOpenArray
<li><a class="reference" href="#macOpenArray.t%2CSecret%2Cint"
title="macOpenArray(secret: Secret; id: int): untyped">macOpenArray(secret: Secret; id: int): untyped</a></li>
</ul>
<ul class="simple nested-toc-section">orError
<li><a class="reference" href="#orError.t%2Cuntyped%2Cuntyped"
title="orError(exp: untyped; err: untyped): untyped">orError(exp: untyped; err: untyped): untyped</a></li>
</ul>
<ul class="simple nested-toc-section">supported
<li><a class="reference" href="#supported.t%2CPKScheme"
title="supported(scheme: PKScheme): bool">supported(scheme: PKScheme): bool</a></li>
</ul>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#19" id="69">Exports</a>
<ul class="simple simple-toc-section">
</ul>
</li>
</ul>
</div>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L1"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
<div class="nine columns" id="content">
<div id="tocRoot"></div>
<p class="module-desc">This module implements Public Key and Private Key interface for libp2p.Serialization/Deserialization helpers</p>
<div class="section" id="6">
<h1><a class="toc-backref" href="#6">Imports</a></h1>
<dl class="item">
<a class="reference external" href="rsa.html">rsa</a>, <a class="reference external" href="ed25519/ed25519.html">ed25519/ed25519</a>, <a class="reference external" href="secp.html">secp</a>, <a class="reference external" href="ecnist.html">ecnist</a>, <a class="reference external" href="../protobuf/minprotobuf.html">../protobuf/minprotobuf</a>, <a class="reference external" href="../vbuffer.html">../vbuffer</a>, <a class="reference external" href="../multihash.html">../multihash</a>, <a class="reference external" href="../multicodec.html">../multicodec</a>, <a class="reference external" href="../utility.html">../utility</a>
</dl></div>
<div class="section" id="7">
<h1><a class="toc-backref" href="#7">Types</a></h1>
<dl class="item">
<div id="CryptoError" class="tohide">
<dt><pre><a href="crypto.html#CryptoError"><span class="Identifier">CryptoError</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
<span class="Identifier">KeyError</span><span class="Other">,</span> <span class="Identifier">SigError</span><span class="Other">,</span> <span class="Identifier">HashError</span><span class="Other">,</span> <span class="Identifier">SchemeError</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L150"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L150" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="CryptoResult" class="tohide">
<dt><pre><a href="crypto.html#CryptoResult"><span class="Identifier">CryptoResult</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span> <span class="Other">=</span> <span class="Identifier">Result</span><span class="Other">[</span><span class="Identifier">T</span><span class="Other">,</span> <a href="crypto.html#CryptoError"><span class="Identifier">CryptoError</span></a><span class="Other">]</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L156"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L156" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="DigestSheme" class="tohide">
<dt><pre><a href="crypto.html#DigestSheme"><span class="Identifier">DigestSheme</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
<span class="Identifier">Sha256</span><span class="Other">,</span> <span class="Identifier">Sha512</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L87"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L87" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="KeyPair" class="tohide">
<dt><pre><a href="crypto.html#KeyPair"><span class="Identifier">KeyPair</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
<span class="Identifier">seckey</span><span class="Operator">*</span><span class="Other">:</span> <a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a>
<span class="Identifier">pubkey</span><span class="Operator">*</span><span class="Other">:</span> <a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a>
</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L137"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L137" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="PKScheme" class="tohide">
<dt><pre><a href="crypto.html#PKScheme"><span class="Identifier">PKScheme</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
<span class="Identifier">RSA</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">,</span> <span class="Identifier">Ed25519</span><span class="Other">,</span> <span class="Identifier">Secp256k1</span><span class="Other">,</span> <span class="Identifier">ECDSA</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L18"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L18" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="PrivateKey" class="tohide">
<dt><pre><a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
<span class="Keyword">case</span> <span class="Identifier">scheme</span><span class="Operator">*</span><span class="Other">:</span> <a href="crypto.html#PKScheme"><span class="Identifier">PKScheme</span></a>
<span class="Keyword">of</span> <span class="Identifier">PKScheme</span><span class="Other">.</span><span class="Identifier">RSA</span><span class="Other">:</span>
<span class="Keyword">when</span> <span class="Identifier">supported</span><span class="Other">(</span><span class="Identifier">PKScheme</span><span class="Other">.</span><span class="Identifier">RSA</span><span class="Other">)</span><span class="Other">:</span>
<span class="Identifier">rsakey</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">rsa</span><span class="Other">.</span><span class="Identifier">RsaPrivateKey</span>
<span class="Keyword">else</span><span class="Other">:</span>
<span class="Keyword">nil</span>
<span class="Keyword">of</span> <span class="Identifier">PKScheme</span><span class="Other">.</span><span class="Identifier">Ed25519</span><span class="Other">:</span>
<span class="Keyword">when</span> <span class="Identifier">supported</span><span class="Other">(</span><span class="Identifier">PKScheme</span><span class="Other">.</span><span class="Identifier">Ed25519</span><span class="Other">)</span><span class="Other">:</span>
<span class="Identifier">edkey</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">EdPrivateKey</span>
<span class="Keyword">else</span><span class="Other">:</span>
<span class="Keyword">nil</span>
<span class="Keyword">of</span> <span class="Identifier">PKScheme</span><span class="Other">.</span><span class="Identifier">Secp256k1</span><span class="Other">:</span>
<span class="Keyword">when</span> <span class="Identifier">supported</span><span class="Other">(</span><span class="Identifier">PKScheme</span><span class="Other">.</span><span class="Identifier">Secp256k1</span><span class="Other">)</span><span class="Other">:</span>
<span class="Identifier">skkey</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">SkPrivateKey</span>
<span class="Keyword">else</span><span class="Other">:</span>
<span class="Keyword">nil</span>
<span class="Keyword">of</span> <span class="Identifier">PKScheme</span><span class="Other">.</span><span class="Identifier">ECDSA</span><span class="Other">:</span>
<span class="Keyword">when</span> <span class="Identifier">supported</span><span class="Other">(</span><span class="Identifier">PKScheme</span><span class="Other">.</span><span class="Identifier">ECDSA</span><span class="Other">)</span><span class="Other">:</span>
<span class="Identifier">eckey</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">ecnist</span><span class="Other">.</span><span class="Identifier">EcPrivateKey</span>
<span class="Keyword">else</span><span class="Other">:</span>
<span class="Keyword">nil</span>
</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L114"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L114" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="PublicKey" class="tohide">
<dt><pre><a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
<span class="Keyword">case</span> <span class="Identifier">scheme</span><span class="Operator">*</span><span class="Other">:</span> <a href="crypto.html#PKScheme"><span class="Identifier">PKScheme</span></a>
<span class="Keyword">of</span> <span class="Identifier">PKScheme</span><span class="Other">.</span><span class="Identifier">RSA</span><span class="Other">:</span>
<span class="Keyword">when</span> <span class="Identifier">PKScheme</span><span class="Other">.</span><span class="Identifier">RSA</span> <span class="Keyword">in</span> <span class="Identifier">SupportedSchemes</span><span class="Other">:</span>
<span class="Identifier">rsakey</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">rsa</span><span class="Other">.</span><span class="Identifier">RsaPublicKey</span>
<span class="Keyword">else</span><span class="Other">:</span>
<span class="Keyword">nil</span>
<span class="Keyword">of</span> <span class="Identifier">PKScheme</span><span class="Other">.</span><span class="Identifier">Ed25519</span><span class="Other">:</span>
<span class="Keyword">when</span> <span class="Identifier">supported</span><span class="Other">(</span><span class="Identifier">PKScheme</span><span class="Other">.</span><span class="Identifier">Ed25519</span><span class="Other">)</span><span class="Other">:</span>
<span class="Identifier">edkey</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">EdPublicKey</span>
<span class="Keyword">else</span><span class="Other">:</span>
<span class="Keyword">nil</span>
<span class="Keyword">of</span> <span class="Identifier">PKScheme</span><span class="Other">.</span><span class="Identifier">Secp256k1</span><span class="Other">:</span>
<span class="Keyword">when</span> <span class="Identifier">supported</span><span class="Other">(</span><span class="Identifier">PKScheme</span><span class="Other">.</span><span class="Identifier">Secp256k1</span><span class="Other">)</span><span class="Other">:</span>
<span class="Identifier">skkey</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">SkPublicKey</span>
<span class="Keyword">else</span><span class="Other">:</span>
<span class="Keyword">nil</span>
<span class="Keyword">of</span> <span class="Identifier">PKScheme</span><span class="Other">.</span><span class="Identifier">ECDSA</span><span class="Other">:</span>
<span class="Keyword">when</span> <span class="Identifier">supported</span><span class="Other">(</span><span class="Identifier">PKScheme</span><span class="Other">.</span><span class="Identifier">ECDSA</span><span class="Other">)</span><span class="Other">:</span>
<span class="Identifier">eckey</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">ecnist</span><span class="Other">.</span><span class="Identifier">EcPublicKey</span>
<span class="Keyword">else</span><span class="Other">:</span>
<span class="Keyword">nil</span>
</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L91"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L91" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="Secret" class="tohide">
<dt><pre><a href="crypto.html#Secret"><span class="Identifier">Secret</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
<span class="Identifier">ivsize</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">int</span>
<span class="Identifier">keysize</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">int</span>
<span class="Identifier">macsize</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">int</span>
<span class="Identifier">data</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span>
</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L141"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L141" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="Signature" class="tohide">
<dt><pre><a href="crypto.html#Signature"><span class="Identifier">Signature</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
<span class="Identifier">data</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span>
</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L147"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L147" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
</dl></div>
<div class="section" id="10">
<h1><a class="toc-backref" href="#10">Consts</a></h1>
<dl class="item">
<div id="libp2p_pki_schemes" class="tohide">
<dt><pre><a href="crypto.html#libp2p_pki_schemes"><span class="Identifier">libp2p_pki_schemes</span></a> <span class="Other">=</span> <span class="StringLit">&quot;rsa,ed25519,secp256k1,ecnist&quot;</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L15"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L15" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="RsaDefaultKeySize" class="tohide">
<dt><pre><a href="crypto.html#RsaDefaultKeySize"><span class="Identifier">RsaDefaultKeySize</span></a> <span class="Other">=</span> <span class="DecNumber">3072</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L56"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L56" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="SupportedSchemes" class="tohide">
<dt><pre><a href="crypto.html#SupportedSchemes"><span class="Identifier">SupportedSchemes</span></a> <span class="Other">=</span> <span class="Other">{</span><span class="DecNumber">RSA</span><span class="Other">,</span> <span class="DecNumber">Ed25519</span><span class="Other">,</span> <span class="DecNumber">Secp256k1</span><span class="Other">,</span> <span class="DecNumber">ECDSA</span><span class="Other">}</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L54"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L54" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="SupportedSchemesInt" class="tohide">
<dt><pre><a href="crypto.html#SupportedSchemesInt"><span class="Identifier">SupportedSchemesInt</span></a> <span class="Other">=</span> <span class="Other">{</span><span class="DecNumber">0</span><span class="Other">,</span> <span class="DecNumber">1</span><span class="Other">,</span> <span class="DecNumber">2</span><span class="Other">,</span> <span class="DecNumber">3</span><span class="Other">}</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L55"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L55" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
</dl></div>
<div class="section" id="12">
<h1><a class="toc-backref" href="#12">Procs</a></h1>
<dl class="item">
<div id="$" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#%24"><span class="Identifier">`$`</span></a><span class="Other">(</span><span class="Identifier">key</span><span class="Other">:</span> <a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a> <span class="Operator">|</span> <a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Get string representation of private/public key <tt class="docutils literal"><span class="pre">key</span></tt>.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L672"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L672" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="$,Signature" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#%24%2CSignature"><span class="Identifier">`$`</span></a><span class="Other">(</span><span class="Identifier">sig</span><span class="Other">:</span> <a href="crypto.html#Signature"><span class="Identifier">Signature</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Get string representation of signature <tt class="docutils literal"><span class="pre">sig</span></tt>.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L720"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L720" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="==,PrivateKey,PrivateKey" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#%3D%3D%2CPrivateKey%2CPrivateKey"><span class="Identifier">`==`</span></a><span class="Other">(</span><span class="Identifier">key1</span><span class="Other">,</span> <span class="Identifier">key2</span><span class="Other">:</span> <a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Return <tt class="docutils literal"><span class="pre">true</span></tt> if two private keys <tt class="docutils literal"><span class="pre">key1</span></tt> and <tt class="docutils literal"><span class="pre">key2</span></tt> of the same scheme and equal.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L644"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L644" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="==,PublicKey,PublicKey" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#%3D%3D%2CPublicKey%2CPublicKey"><span class="Identifier">`==`</span></a><span class="Other">(</span><span class="Identifier">key1</span><span class="Other">,</span> <span class="Identifier">key2</span><span class="Other">:</span> <a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Return <tt class="docutils literal"><span class="pre">true</span></tt> if two public keys <tt class="docutils literal"><span class="pre">key1</span></tt> and <tt class="docutils literal"><span class="pre">key2</span></tt> of the same scheme and equal.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L616"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L616" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="createExchange,openArray[byte],openArray[byte]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#createExchange%2CopenArray%5Bbyte%5D%2CopenArray%5Bbyte%5D"><span class="Identifier">createExchange</span></a><span class="Other">(</span><span class="Identifier">epubkey</span><span class="Other">,</span> <span class="Identifier">signature</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Create SecIO exchange message using ephemeral public key <tt class="docutils literal"><span class="pre">epubkey</span></tt> and signature of proposal blocks <tt class="docutils literal"><span class="pre">signature</span></tt>.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L960"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L960" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="createProposal,openArray[byte],openArray[byte],string,string,string" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#createProposal%2CopenArray%5Bbyte%5D%2CopenArray%5Bbyte%5D%2Cstring%2Cstring%2Cstring"><span class="Identifier">createProposal</span></a><span class="Other">(</span><span class="Identifier">nonce</span><span class="Other">,</span> <span class="Identifier">pubkey</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">;</span>
<span class="Identifier">exchanges</span><span class="Other">,</span> <span class="Identifier">ciphers</span><span class="Other">,</span> <span class="Identifier">hashes</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Create SecIO proposal message using random <tt class="docutils literal"><span class="pre">nonce</span></tt>, local public key <tt class="docutils literal"><span class="pre">pubkey</span></tt>, comma-delimieted list of supported exchange schemes <tt class="docutils literal"><span class="pre">exchanges</span></tt>, comma-delimeted list of supported ciphers <tt class="docutils literal"><span class="pre">ciphers</span></tt> and comma-delimeted list of supported hashes <tt class="docutils literal"><span class="pre">hashes</span></tt>.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L927"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L927" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="decodeExchange,seq[byte],seq[byte],seq[byte]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#decodeExchange%2Cseq%5Bbyte%5D%2Cseq%5Bbyte%5D%2Cseq%5Bbyte%5D"><span class="Identifier">decodeExchange</span></a><span class="Other">(</span><span class="Identifier">message</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">pubkey</span><span class="Other">,</span> <span class="Identifier">signature</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Parse incoming exchange message and decode remote ephemeral public key <tt class="docutils literal"><span class="pre">pubkey</span></tt> and signature <tt class="docutils literal"><span class="pre">signature</span></tt>.</p>
<p>Procedure returns <tt class="docutils literal"><span class="pre">true</span></tt> on success and <tt class="docutils literal"><span class="pre">false</span></tt> on error.</p>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L969"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L969" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="decodeProposal,seq[byte],seq[byte],seq[byte],string,string,string" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#decodeProposal%2Cseq%5Bbyte%5D%2Cseq%5Bbyte%5D%2Cseq%5Bbyte%5D%2Cstring%2Cstring%2Cstring"><span class="Identifier">decodeProposal</span></a><span class="Other">(</span><span class="Identifier">message</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">nonce</span><span class="Other">,</span> <span class="Identifier">pubkey</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">;</span>
<span class="Identifier">exchanges</span><span class="Other">,</span> <span class="Identifier">ciphers</span><span class="Other">,</span> <span class="Identifier">hashes</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Parse incoming proposal message and decode remote random nonce <tt class="docutils literal"><span class="pre">nonce</span></tt>, remote public key <tt class="docutils literal"><span class="pre">pubkey</span></tt>, comma-delimieted list of supported exchange schemes <tt class="docutils literal"><span class="pre">exchanges</span></tt>, comma-delimeted list of supported ciphers <tt class="docutils literal"><span class="pre">ciphers</span></tt> and comma-delimeted list of supported hashes <tt class="docutils literal"><span class="pre">hashes</span></tt>.</p>
<p>Procedure returns <tt class="docutils literal"><span class="pre">true</span></tt> on success and <tt class="docutils literal"><span class="pre">false</span></tt> on error.</p>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L942"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L942" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getBytes,PrivateKey" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#getBytes%2CPrivateKey"><span class="Identifier">getBytes</span></a><span class="Other">(</span><span class="Identifier">key</span><span class="Other">:</span> <a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#CryptoResult"><span class="Identifier">CryptoResult</span></a><span class="Other">[</span><span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Return private key <tt class="docutils literal"><span class="pre">key</span></tt> in binary form (using libp2p's protobuf serialization).
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L436"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L436" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getBytes,PublicKey" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#getBytes%2CPublicKey"><span class="Identifier">getBytes</span></a><span class="Other">(</span><span class="Identifier">key</span><span class="Other">:</span> <a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#CryptoResult"><span class="Identifier">CryptoResult</span></a><span class="Other">[</span><span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Return public key <tt class="docutils literal"><span class="pre">key</span></tt> in binary form (using libp2p's protobuf serialization).
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L445"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L445" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getBytes,Signature" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#getBytes%2CSignature"><span class="Identifier">getBytes</span></a><span class="Other">(</span><span class="Identifier">sig</span><span class="Other">:</span> <a href="crypto.html#Signature"><span class="Identifier">Signature</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Return signature <tt class="docutils literal"><span class="pre">sig</span></tt> in binary form.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L454"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L454" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getField,ProtoBuffer,int,Signature" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#getField%2CProtoBuffer%2Cint%2CSignature"><span class="Identifier">getField</span></a><span class="Other">(</span><span class="Identifier">pb</span><span class="Other">:</span> <a href="../protobuf/minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">;</span> <span class="Identifier">field</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="crypto.html#Signature"><span class="Identifier">Signature</span></a><span class="Other">)</span><span class="Other">:</span> <a href="../protobuf/minprotobuf.html#ProtoResult"><span class="Identifier">ProtoResult</span></a><span class="Other">[</span>
<span class="Identifier">bool</span><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Deserialize signature from protobuf's message <tt class="docutils literal"><span class="pre">pb</span></tt> using field index <tt class="docutils literal"><span class="pre">field</span></tt>.</p>
<p>On success deserialized signature will be stored in <tt class="docutils literal"><span class="pre">value</span></tt>.</p>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L1024"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L1024" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getField,ProtoBuffer,int,T" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#getField%2CProtoBuffer%2Cint%2CT"><span class="Identifier">getField</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a> <span class="Operator">|</span> <a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">pb</span><span class="Other">:</span> <a href="../protobuf/minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">;</span> <span class="Identifier">field</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">;</span>
<span class="Identifier">value</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <a href="../protobuf/minprotobuf.html#ProtoResult"><span class="Identifier">ProtoResult</span></a><span class="Other">[</span><span class="Identifier">bool</span><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Deserialize public/private key from protobuf's message <tt class="docutils literal"><span class="pre">pb</span></tt> using field index <tt class="docutils literal"><span class="pre">field</span></tt>.</p>
<p>On success deserialized key will be stored in <tt class="docutils literal"><span class="pre">value</span></tt>.</p>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L1006"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L1006" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getOrder,openArray[byte],openArray[byte],openArray[byte],openArray[byte]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#getOrder%2CopenArray%5Bbyte%5D%2CopenArray%5Bbyte%5D%2CopenArray%5Bbyte%5D%2CopenArray%5Bbyte%5D"><span class="Identifier">getOrder</span></a><span class="Other">(</span><span class="Identifier">remotePubkey</span><span class="Other">,</span> <span class="Identifier">localNonce</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">;</span>
<span class="Identifier">localPubkey</span><span class="Other">,</span> <span class="Identifier">remoteNonce</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#CryptoResult"><span class="Identifier">CryptoResult</span></a><span class="Other">[</span><span class="Identifier">int</span><span class="Other">]</span> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Compare values and calculate <tt class="docutils literal"><span class="pre"><span class="Identifier">order</span></span></tt> parameter.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L882"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L882" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getPublicKey,PrivateKey" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#getPublicKey%2CPrivateKey"><span class="Identifier">getPublicKey</span></a><span class="Other">(</span><span class="Identifier">key</span><span class="Other">:</span> <a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#CryptoResult"><span class="Identifier">CryptoResult</span></a><span class="Other">[</span><a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Get public key from corresponding private key <tt class="docutils literal"><span class="pre">key</span></tt>.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L319"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L319" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getRawBytes" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#getRawBytes"><span class="Identifier">getRawBytes</span></a><span class="Other">(</span><span class="Identifier">key</span><span class="Other">:</span> <a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a> <span class="Operator">|</span> <a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#CryptoResult"><span class="Identifier">CryptoResult</span></a><span class="Other">[</span><span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">]</span> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Return private key <tt class="docutils literal"><span class="pre">key</span></tt> in binary form (using scheme's own serialization).
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L375"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L375" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="init,PrivateKey,openArray[byte]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#init%2CPrivateKey%2CopenArray%5Bbyte%5D"><span class="Identifier">init</span></a><span class="Other">(</span><span class="Identifier">key</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L522"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L522" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="init,PublicKey,openArray[byte]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#init%2CPublicKey%2CopenArray%5Bbyte%5D"><span class="Identifier">init</span></a><span class="Other">(</span><span class="Identifier">key</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L525"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L525" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="init,Signature,openArray[byte]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#init%2CSignature%2CopenArray%5Bbyte%5D"><span class="Identifier">init</span></a><span class="Other">(</span><span class="Identifier">sig</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="crypto.html#Signature"><span class="Identifier">Signature</span></a><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Initialize signature <tt class="docutils literal"><span class="pre">sig</span></tt> from raw binary form.</p>
<p>Returns <tt class="docutils literal"><span class="pre">true</span></tt> on success.</p>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L529"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L529" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="init,Signature,string" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#init%2CSignature%2Cstring"><span class="Identifier">init</span></a><span class="Other">(</span><span class="Identifier">sig</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="crypto.html#Signature"><span class="Identifier">Signature</span></a><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Initialize signature <tt class="docutils literal"><span class="pre">sig</span></tt> from serialized hexadecimal string representation.</p>
<p>Returns <tt class="docutils literal"><span class="pre">true</span></tt> on success.</p>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L544"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L544" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="init,typedesc[PrivateKey],openArray[byte]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#init%2Ctypedesc%5BPrivateKey%5D%2CopenArray%5Bbyte%5D"><span class="Identifier">init</span></a><span class="Other">(</span><span class="Identifier">t</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#CryptoResult"><span class="Identifier">CryptoResult</span></a><span class="Other">[</span>
<a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Create new private key from libp2p's protobuf serialized binary form.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L551"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L551" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="init,typedesc[PrivateKey],string" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#init%2Ctypedesc%5BPrivateKey%5D%2Cstring"><span class="Identifier">init</span></a><span class="Other">(</span><span class="Identifier">t</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#CryptoResult"><span class="Identifier">CryptoResult</span></a><span class="Other">[</span><a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">]</span> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Create new private key from libp2p's protobuf serialized hexadecimal string form.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L578"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L578" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="init,typedesc[PrivateKey],_2" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#init%2Ctypedesc%5BPrivateKey%5D%2C_2"><span class="Identifier">init</span></a><span class="Other">(</span><span class="Identifier">t</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</span><span class="Other">:</span> <span class="Identifier">ecnist</span><span class="Other">.</span><span class="Identifier">EcPrivateKey</span><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L602"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L602" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="init,typedesc[PrivateKey],EdPrivateKey" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#init%2Ctypedesc%5BPrivateKey%5D%2CEdPrivateKey"><span class="Identifier">init</span></a><span class="Other">(</span><span class="Identifier">t</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</span><span class="Other">:</span> <a href="ed25519/ed25519.html#EdPrivateKey"><span class="Identifier">EdPrivateKey</span></a><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L590"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L590" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="init,typedesc[PrivateKey]," class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#init%2Ctypedesc%5BPrivateKey%5D%2C"><span class="Identifier">init</span></a><span class="Other">(</span><span class="Identifier">t</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</span><span class="Other">:</span> <span class="Identifier">rsa</span><span class="Other">.</span><span class="Identifier">RsaPrivateKey</span><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L584"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L584" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="init,typedesc[PrivateKey],SkPrivateKey" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#init%2Ctypedesc%5BPrivateKey%5D%2CSkPrivateKey"><span class="Identifier">init</span></a><span class="Other">(</span><span class="Identifier">t</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</span><span class="Other">:</span> <a href="secp.html#SkPrivateKey"><span class="Identifier">SkPrivateKey</span></a><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L596"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L596" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="init,typedesc[PublicKey],openArray[byte]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#init%2Ctypedesc%5BPublicKey%5D%2CopenArray%5Bbyte%5D"><span class="Identifier">init</span></a><span class="Other">(</span><span class="Identifier">t</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#CryptoResult"><span class="Identifier">CryptoResult</span></a><span class="Other">[</span><a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">]</span> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Create new public key from libp2p's protobuf serialized binary form.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L560"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L560" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="init,typedesc[PublicKey],string" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#init%2Ctypedesc%5BPublicKey%5D%2Cstring"><span class="Identifier">init</span></a><span class="Other">(</span><span class="Identifier">t</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#CryptoResult"><span class="Identifier">CryptoResult</span></a><span class="Other">[</span><a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">]</span> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Create new public key from libp2p's protobuf serialized hexadecimal string form.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L607"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L607" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="init,typedesc[PublicKey],_2" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#init%2Ctypedesc%5BPublicKey%5D%2C_2"><span class="Identifier">init</span></a><span class="Other">(</span><span class="Identifier">t</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</span><span class="Other">:</span> <span class="Identifier">ecnist</span><span class="Other">.</span><span class="Identifier">EcPublicKey</span><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L604"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L604" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="init,typedesc[PublicKey],EdPublicKey" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#init%2Ctypedesc%5BPublicKey%5D%2CEdPublicKey"><span class="Identifier">init</span></a><span class="Other">(</span><span class="Identifier">t</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</span><span class="Other">:</span> <a href="ed25519/ed25519.html#EdPublicKey"><span class="Identifier">EdPublicKey</span></a><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L592"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L592" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="init,typedesc[PublicKey]," class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#init%2Ctypedesc%5BPublicKey%5D%2C"><span class="Identifier">init</span></a><span class="Other">(</span><span class="Identifier">t</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</span><span class="Other">:</span> <span class="Identifier">rsa</span><span class="Other">.</span><span class="Identifier">RsaPublicKey</span><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L586"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L586" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="init,typedesc[PublicKey],SkPublicKey" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#init%2Ctypedesc%5BPublicKey%5D%2CSkPublicKey"><span class="Identifier">init</span></a><span class="Other">(</span><span class="Identifier">t</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</span><span class="Other">:</span> <a href="secp.html#SkPublicKey"><span class="Identifier">SkPublicKey</span></a><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L598"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L598" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="init,typedesc[Signature],openArray[byte]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#init%2Ctypedesc%5BSignature%5D%2CopenArray%5Bbyte%5D"><span class="Identifier">init</span></a><span class="Other">(</span><span class="Identifier">t</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><a href="crypto.html#Signature"><span class="Identifier">Signature</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#CryptoResult"><span class="Identifier">CryptoResult</span></a><span class="Other">[</span><a href="crypto.html#Signature"><span class="Identifier">Signature</span></a><span class="Other">]</span> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Create new public key from libp2p's protobuf serialized binary form.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L569"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L569" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="init,typedesc[Signature],string" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#init%2Ctypedesc%5BSignature%5D%2Cstring"><span class="Identifier">init</span></a><span class="Other">(</span><span class="Identifier">t</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><a href="crypto.html#Signature"><span class="Identifier">Signature</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#CryptoResult"><span class="Identifier">CryptoResult</span></a><span class="Other">[</span><a href="crypto.html#Signature"><span class="Identifier">Signature</span></a><span class="Other">]</span> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Create new signature from serialized hexadecimal string form.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L612"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L612" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="init,T,string" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#init%2CT%2Cstring"><span class="Identifier">init</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a> <span class="Operator">|</span> <a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">key</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Initialize private/public key <tt class="docutils literal"><span class="pre">key</span></tt> from libp2p's protobuf serialized hexadecimal string representation.</p>
<p>Returns <tt class="docutils literal"><span class="pre">true</span></tt> on success.</p>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L537"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L537" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="iv,Secret,int" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#iv%2CSecret%2Cint"><span class="Identifier">iv</span></a><span class="Other">(</span><span class="Identifier">secret</span><span class="Other">:</span> <a href="crypto.html#Secret"><span class="Identifier">Secret</span></a><span class="Other">;</span> <span class="Identifier">id</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Get array of bytes with with initial vector.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L864"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L864" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="key,Secret,int" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#key%2CSecret%2Cint"><span class="Identifier">key</span></a><span class="Other">(</span><span class="Identifier">secret</span><span class="Other">:</span> <a href="crypto.html#Secret"><span class="Identifier">Secret</span></a><span class="Other">;</span> <span class="Identifier">id</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L870"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L870" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="mac,Secret,int" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#mac%2CSecret%2Cint"><span class="Identifier">mac</span></a><span class="Other">(</span><span class="Identifier">secret</span><span class="Other">:</span> <a href="crypto.html#Secret"><span class="Identifier">Secret</span></a><span class="Other">;</span> <span class="Identifier">id</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L876"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L876" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="newRng" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#newRng"><span class="Identifier">newRng</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Keyword">ref</span> <span class="Identifier">HmacDrbgContext</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L161"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L161" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="random,typedesc[KeyPair],HmacDrbgContext" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#random%2Ctypedesc%5BKeyPair%5D%2CHmacDrbgContext"><span class="Identifier">random</span></a><span class="Other">(</span><span class="Identifier">T</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><a href="crypto.html#KeyPair"><span class="Identifier">KeyPair</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">rng</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">HmacDrbgContext</span><span class="Other">;</span>
<span class="Identifier">bits</span> <span class="Other">=</span> <span class="Identifier">RsaDefaultKeySize</span><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#CryptoResult"><span class="Identifier">CryptoResult</span></a><span class="Other">[</span><a href="crypto.html#KeyPair"><span class="Identifier">KeyPair</span></a><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Generate random private pair of keys using default public-key cryptography scheme.</p>
<p>Default public-key cryptography schemes are following order: ed25519, secp256k1, RSA, secp256r1.</p>
<p>So will be used first available (supported) method.</p>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L287"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L287" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="random,typedesc[KeyPair],PKScheme,HmacDrbgContext" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#random%2Ctypedesc%5BKeyPair%5D%2CPKScheme%2CHmacDrbgContext"><span class="Identifier">random</span></a><span class="Other">(</span><span class="Identifier">T</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><a href="crypto.html#KeyPair"><span class="Identifier">KeyPair</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">scheme</span><span class="Other">:</span> <a href="crypto.html#PKScheme"><span class="Identifier">PKScheme</span></a><span class="Other">;</span> <span class="Identifier">rng</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">HmacDrbgContext</span><span class="Other">;</span>
<span class="Identifier">bits</span> <span class="Other">=</span> <span class="Identifier">RsaDefaultKeySize</span><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#CryptoResult"><span class="Identifier">CryptoResult</span></a><span class="Other">[</span><a href="crypto.html#KeyPair"><span class="Identifier">KeyPair</span></a><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Generate random key pair for scheme <tt class="docutils literal"><span class="pre">scheme</span></tt>.</p>
<p><tt class="docutils literal"><span class="pre">bits</span></tt> is number of bits for RSA key, <tt class="docutils literal"><span class="pre">bits</span></tt> value must be in [512, 4096], default value is 2048 bits.</p>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L246"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L246" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="random,typedesc[PrivateKey],HmacDrbgContext" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#random%2Ctypedesc%5BPrivateKey%5D%2CHmacDrbgContext"><span class="Identifier">random</span></a><span class="Other">(</span><span class="Identifier">T</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">rng</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">HmacDrbgContext</span><span class="Other">;</span>
<span class="Identifier">bits</span> <span class="Other">=</span> <span class="Identifier">RsaDefaultKeySize</span><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#CryptoResult"><span class="Identifier">CryptoResult</span></a><span class="Other">[</span><a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Generate random private key using default public-key cryptography scheme.</p>
<p>Default public-key cryptography schemes are following order: ed25519, secp256k1, RSA, secp256r1.</p>
<p>So will be used first available (supported) method.</p>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L223"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L223" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="random,typedesc[PrivateKey],PKScheme,HmacDrbgContext" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#random%2Ctypedesc%5BPrivateKey%5D%2CPKScheme%2CHmacDrbgContext"><span class="Identifier">random</span></a><span class="Other">(</span><span class="Identifier">T</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">scheme</span><span class="Other">:</span> <a href="crypto.html#PKScheme"><span class="Identifier">PKScheme</span></a><span class="Other">;</span> <span class="Identifier">rng</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">HmacDrbgContext</span><span class="Other">;</span>
<span class="Identifier">bits</span> <span class="Other">=</span> <span class="Identifier">RsaDefaultKeySize</span><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#CryptoResult"><span class="Identifier">CryptoResult</span></a><span class="Other">[</span><a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Generate random private key for scheme <tt class="docutils literal"><span class="pre">scheme</span></tt>.</p>
<p><tt class="docutils literal"><span class="pre">bits</span></tt> is number of bits for RSA key, <tt class="docutils literal"><span class="pre">bits</span></tt> value must be in [2048, 4096], default value is 3072 bits.</p>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L190"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L190" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="selectBest,int,string,string" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#selectBest%2Cint%2Cstring%2Cstring"><span class="Identifier">selectBest</span></a><span class="Other">(</span><span class="Identifier">order</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">;</span> <span class="Identifier">p1</span><span class="Other">,</span> <span class="Identifier">p2</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Determines which algorithm to use from list <tt class="docutils literal"><span class="pre"><span class="Identifier">p1</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">p2</span></span></tt>.</p>
<p>Returns empty string if there no algorithms in common.</p>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L907"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L907" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="shortLog" class="tohide">
<dt><pre><span class="Keyword">func</span> <a href="#shortLog"><span class="Identifier">shortLog</span></a><span class="Other">(</span><span class="Identifier">key</span><span class="Other">:</span> <a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a> <span class="Operator">|</span> <a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Get short string representation of private/public key <tt class="docutils literal"><span class="pre">key</span></tt>.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L696"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L696" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="shuffle,ref.HmacDrbgContext,openArray[T]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#shuffle%2Cref.HmacDrbgContext%2CopenArray%5BT%5D"><span class="Identifier">shuffle</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">rng</span><span class="Other">:</span> <span class="Keyword">ref</span> <span class="Identifier">HmacDrbgContext</span><span class="Other">;</span> <span class="Identifier">x</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L175"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L175" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="sign,PrivateKey,openArray[byte]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#sign%2CPrivateKey%2CopenArray%5Bbyte%5D"><span class="Identifier">sign</span></a><span class="Other">(</span><span class="Identifier">key</span><span class="Other">:</span> <a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#CryptoResult"><span class="Identifier">CryptoResult</span></a><span class="Other">[</span><a href="crypto.html#Signature"><span class="Identifier">Signature</span></a><span class="Other">]</span> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Sign message <tt class="docutils literal"><span class="pre">data</span></tt> using private key <tt class="docutils literal"><span class="pre">key</span></tt> and return generated signature in raw binary form.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L724"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L724" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="stretchKeys,string,string,seq[byte]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#stretchKeys%2Cstring%2Cstring%2Cseq%5Bbyte%5D"><span class="Identifier">stretchKeys</span></a><span class="Other">(</span><span class="Identifier">cipherType</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">hashType</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">sharedSecret</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#Secret"><span class="Identifier">Secret</span></a> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Expand shared secret to cryptographic keys.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L826"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L826" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="toBytes,PrivateKey,openArray[byte]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#toBytes%2CPrivateKey%2CopenArray%5Bbyte%5D"><span class="Identifier">toBytes</span></a><span class="Other">(</span><span class="Identifier">key</span><span class="Other">:</span> <a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#CryptoResult"><span class="Identifier">CryptoResult</span></a><span class="Other">[</span><span class="Identifier">int</span><span class="Other">]</span> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Serialize private key <tt class="docutils literal"><span class="pre">key</span></tt> (using libp2p protobuf scheme) and store it to <tt class="docutils literal"><span class="pre">data</span></tt>.</p>
<p>Returns number of bytes (octets) needed to store private key <tt class="docutils literal"><span class="pre">key</span></tt>.</p>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L400"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L400" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="toBytes,PublicKey,openArray[byte]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#toBytes%2CPublicKey%2CopenArray%5Bbyte%5D"><span class="Identifier">toBytes</span></a><span class="Other">(</span><span class="Identifier">key</span><span class="Other">:</span> <a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#CryptoResult"><span class="Identifier">CryptoResult</span></a><span class="Other">[</span><span class="Identifier">int</span><span class="Other">]</span> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Serialize public key <tt class="docutils literal"><span class="pre">key</span></tt> (using libp2p protobuf scheme) and store it to <tt class="docutils literal"><span class="pre">data</span></tt>.</p>
<p>Returns number of bytes (octets) needed to store public key <tt class="docutils literal"><span class="pre">key</span></tt>.</p>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L414"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L414" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="toBytes,Signature,openArray[byte]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#toBytes%2CSignature%2CopenArray%5Bbyte%5D"><span class="Identifier">toBytes</span></a><span class="Other">(</span><span class="Identifier">sig</span><span class="Other">:</span> <a href="crypto.html#Signature"><span class="Identifier">Signature</span></a><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">int</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Serialize signature <tt class="docutils literal"><span class="pre">sig</span></tt> and store it to <tt class="docutils literal"><span class="pre">data</span></tt>.</p>
<p>Returns number of bytes (octets) needed to store signature <tt class="docutils literal"><span class="pre">sig</span></tt>.</p>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L428"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L428" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="toRawBytes,,openArray[byte]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#toRawBytes%2C%2CopenArray%5Bbyte%5D"><span class="Identifier">toRawBytes</span></a><span class="Other">(</span><span class="Identifier">key</span><span class="Other">:</span> <a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a> <span class="Operator">|</span> <a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="crypto.html#CryptoResult"><span class="Identifier">CryptoResult</span></a><span class="Other">[</span>
<span class="Identifier">int</span><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Serialize private key <tt class="docutils literal"><span class="pre">key</span></tt> (using scheme's own serialization) and store it to <tt class="docutils literal"><span class="pre">data</span></tt>.</p>
<p>Returns number of bytes (octets) needed to store private key <tt class="docutils literal"><span class="pre">key</span></tt>.</p>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L347"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L347" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="verify,Signature,openArray[byte],PublicKey" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#verify%2CSignature%2CopenArray%5Bbyte%5D%2CPublicKey"><span class="Identifier">verify</span></a><span class="Other">(</span><span class="Identifier">sig</span><span class="Other">:</span> <a href="crypto.html#Signature"><span class="Identifier">Signature</span></a><span class="Other">;</span> <span class="Identifier">message</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</span><span class="Other">:</span> <a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Verify signature <tt class="docutils literal"><span class="pre">sig</span></tt> using message <tt class="docutils literal"><span class="pre">message</span></tt> and public key <tt class="docutils literal"><span class="pre">key</span></tt>. Return <tt class="docutils literal"><span class="pre">true</span></tt> if message signature is valid.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L759"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L759" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="write,ProtoBuffer,int,Signature" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#write%2CProtoBuffer%2Cint%2CSignature"><span class="Identifier">write</span></a><span class="Other">(</span><span class="Identifier">pb</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="../protobuf/minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">;</span> <span class="Identifier">field</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">;</span> <span class="Identifier">sig</span><span class="Other">:</span> <a href="crypto.html#Signature"><span class="Identifier">Signature</span></a><span class="Other">)</span> {.<span class="Identifier">inline</span><span class="Other">,</span>
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L1002"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L1002" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="write,VBuffer,PublicKey" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#write%2CVBuffer%2CPublicKey"><span class="Identifier">write</span></a><span class="Other">(</span><span class="Identifier">vb</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="../vbuffer.html#VBuffer"><span class="Identifier">VBuffer</span></a><span class="Other">;</span> <span class="Identifier">pubkey</span><span class="Other">:</span> <a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a><span class="Other">)</span> {.<span class="Identifier">inline</span><span class="Other">,</span>
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ResultError</span><span class="Other">[</span><a href="crypto.html#CryptoError"><span class="Identifier">CryptoError</span></a><span class="Other">]</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Write PublicKey value <tt class="docutils literal"><span class="pre">pubkey</span></tt> to buffer <tt class="docutils literal"><span class="pre">vb</span></tt>.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L982"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L982" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="write,VBuffer,PrivateKey" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#write%2CVBuffer%2CPrivateKey"><span class="Identifier">write</span></a><span class="Other">(</span><span class="Identifier">vb</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="../vbuffer.html#VBuffer"><span class="Identifier">VBuffer</span></a><span class="Other">;</span> <span class="Identifier">seckey</span><span class="Other">:</span> <a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">)</span> {.<span class="Identifier">inline</span><span class="Other">,</span>
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ResultError</span><span class="Other">[</span><a href="crypto.html#CryptoError"><span class="Identifier">CryptoError</span></a><span class="Other">]</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Write PrivateKey value <tt class="docutils literal"><span class="pre">seckey</span></tt> to buffer <tt class="docutils literal"><span class="pre">vb</span></tt>.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L987"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L987" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="write,VBuffer,PrivateKey_2" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#write%2CVBuffer%2CPrivateKey_2"><span class="Identifier">write</span></a><span class="Other">(</span><span class="Identifier">vb</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="../vbuffer.html#VBuffer"><span class="Identifier">VBuffer</span></a><span class="Other">;</span> <span class="Identifier">sig</span><span class="Other">:</span> <a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">)</span> {.<span class="Identifier">inline</span><span class="Other">,</span>
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ResultError</span><span class="Other">[</span><a href="crypto.html#CryptoError"><span class="Identifier">CryptoError</span></a><span class="Other">]</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Write Signature value <tt class="docutils literal"><span class="pre">sig</span></tt> to buffer <tt class="docutils literal"><span class="pre">vb</span></tt>.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L992"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L992" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="write,ProtoBuffer,int,T" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#write%2CProtoBuffer%2Cint%2CT"><span class="Identifier">write</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="crypto.html#PublicKey"><span class="Identifier">PublicKey</span></a> <span class="Operator">|</span> <a href="crypto.html#PrivateKey"><span class="Identifier">PrivateKey</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">pb</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="../protobuf/minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">;</span> <span class="Identifier">field</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">;</span> <span class="Identifier">key</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span> {.
<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ResultError</span><span class="Other">[</span><a href="crypto.html#CryptoError"><span class="Identifier">CryptoError</span></a><span class="Other">]</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L997"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L997" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
</dl></div>
<div class="section" id="18">
<h1><a class="toc-backref" href="#18">Templates</a></h1>
<dl class="item">
<div id="goffset.t,untyped,untyped,untyped" class="tohide">
<dt><pre><span class="Keyword">template</span> <a href="#goffset.t%2Cuntyped%2Cuntyped%2Cuntyped"><span class="Identifier">goffset</span></a><span class="Other">(</span><span class="Identifier">secret</span><span class="Other">,</span> <span class="Identifier">id</span><span class="Other">,</span> <span class="Identifier">o</span><span class="Other">:</span> <span class="Identifier">untyped</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">untyped</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L849"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L849" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="ivOpenArray.t,Secret,int" class="tohide">
<dt><pre><span class="Keyword">template</span> <a href="#ivOpenArray.t%2CSecret%2Cint"><span class="Identifier">ivOpenArray</span></a><span class="Other">(</span><span class="Identifier">secret</span><span class="Other">:</span> <a href="crypto.html#Secret"><span class="Identifier">Secret</span></a><span class="Other">;</span> <span class="Identifier">id</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">untyped</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L852"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L852" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="keyOpenArray.t,Secret,int" class="tohide">
<dt><pre><span class="Keyword">template</span> <a href="#keyOpenArray.t%2CSecret%2Cint"><span class="Identifier">keyOpenArray</span></a><span class="Other">(</span><span class="Identifier">secret</span><span class="Other">:</span> <a href="crypto.html#Secret"><span class="Identifier">Secret</span></a><span class="Other">;</span> <span class="Identifier">id</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">untyped</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L856"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L856" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="macOpenArray.t,Secret,int" class="tohide">
<dt><pre><span class="Keyword">template</span> <a href="#macOpenArray.t%2CSecret%2Cint"><span class="Identifier">macOpenArray</span></a><span class="Other">(</span><span class="Identifier">secret</span><span class="Other">:</span> <a href="crypto.html#Secret"><span class="Identifier">Secret</span></a><span class="Other">;</span> <span class="Identifier">id</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">untyped</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L860"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L860" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="orError.t,untyped,untyped" class="tohide">
<dt><pre><span class="Keyword">template</span> <a href="#orError.t%2Cuntyped%2Cuntyped"><span class="Identifier">orError</span></a><span class="Other">(</span><span class="Identifier">exp</span><span class="Other">:</span> <span class="Identifier">untyped</span><span class="Other">;</span> <span class="Identifier">err</span><span class="Other">:</span> <span class="Identifier">untyped</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">untyped</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L158"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L158" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="supported.t,PKScheme" class="tohide">
<dt><pre><span class="Keyword">template</span> <a href="#supported.t%2CPKScheme"><span class="Identifier">supported</span></a><span class="Other">(</span><span class="Identifier">scheme</span><span class="Other">:</span> <a href="crypto.html#PKScheme"><span class="Identifier">PKScheme</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span></pre></dt>
<dd>
Returns true if specified <tt class="docutils literal"><span class="pre">scheme</span></tt> is currently available.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/move-transport-interop-tests/libp2p/crypto/crypto.nim#L58"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/crypto/crypto.nim#L58" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
</dl></div>
<div class="section" id="19">
<h1><a class="toc-backref" href="#19">Exports</a></h1>
<dl class="item">
<a href="ecnist.html#ephemeral,EcCurveKind,HmacDrbgContext"><span class="Identifier">ephemeral</span></a>, <a href="ecnist.html#ephemeral,string,HmacDrbgContext"><span class="Identifier">ephemeral</span></a>, <a href="ecnist.html#ECDHEScheme"><span class="Identifier">ECDHEScheme</span></a>, <a href="../utility.html#withValue.t,,untyped,untyped"><span class="Identifier">withValue</span></a>, <a href="../utility.html#safeConvert.t,S"><span class="Identifier">safeConvert</span></a>, <a href="../utility.html#shortLog,openArray[byte]"><span class="Identifier">shortLog</span></a>, <a href="../utility.html#withValue.m,,untyped,untyped,untyped"><span class="Identifier">withValue</span></a>, <a href="../utility.html#public.t"><span class="Identifier">public</span></a>, <a href="../utility.html#exceptionToAssert.t,untyped"><span class="Identifier">exceptionToAssert</span></a>, <a href="../utility.html#valueOr.t,Option[T],untyped"><span class="Identifier">valueOr</span></a>, <a href="../utility.html#shortLog,string"><span class="Identifier">shortLog</span></a>, <a href="../utility.html#compilesOr.t,untyped,untyped"><span class="Identifier">compilesOr</span></a>, <a href="../utility.html#capLen,seq[T],Natural"><span class="Identifier">capLen</span></a>, <a href="../utility.html#toOpt.t,Result[T,E]"><span class="Identifier">toOpt</span></a>
</dl></div>
</div>
</div>
<div class="row">
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small style="color: var(--hint);">Made with Nim. Generated: 2024-02-26 14:58:57 UTC</small>
</div>
</div>
</div>
</div>
</body>
</html>