Skip to content

Instantly share code, notes, and snippets.

View Zenithar's full-sized avatar

Thibault NORMAND Zenithar

View GitHub Profile
@Zenithar
Zenithar / hperf.go
Last active February 27, 2024 15:53
Run hash function benchmark on 1GB file content.
package main
import (
"crypto"
"regexp"
"testing"
_ "crypto/sha256"
_ "crypto/sha512"
@Zenithar
Zenithar / gojson_tranform.go
Created November 24, 2023 14:50
Transform JSON with GO
package main
import (
"bufio"
"encoding/json"
"fmt"
"io"
"os"
"time"
package main
import (
"crypto/ecdh"
"crypto/rand"
"crypto/sha256"
"fmt"
"io"
"os"
@Zenithar
Zenithar / eccompressor.go
Last active October 12, 2023 10:17
Provide CP-256, CP-384, CP-521 Y point resolution from an OKP serialized X point - https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-dnhpke-02#section-4.1.1
package main
import (
"crypto/elliptic"
"encoding/hex"
"fmt"
"math/big"
)
// https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-dnhpke-02#section-4.1.1
@Zenithar
Zenithar / dhkem.go
Last active October 9, 2023 16:10
This is an implementation of DHKEM described in RFC9180 - https://datatracker.ietf.org/doc/rfc9180/
package dhkem
import (
"crypto/ecdh"
"crypto/rand"
"encoding/binary"
"errors"
"fmt"
"hash"
"io"
@Zenithar
Zenithar / pinned_dialer.go
Last active October 3, 2023 07:12
Pinned TLS Dialer for Go
package main
import (
"context"
"crypto/sha256"
"crypto/subtle"
"crypto/tls"
"crypto/x509"
"crypto/x509/pkix"
"encoding/asn1"
package main
import (
"crypto/hmac"
"crypto/rand"
"crypto/sha256"
"crypto/subtle"
"encoding/binary"
"encoding/hex"
"fmt"
@Zenithar
Zenithar / zkpauth.go
Last active September 16, 2023 17:46
SMP / ZKP based secure comparison for authentication purpose.
package main
import (
"crypto/ed25519"
"crypto/rand"
"crypto/sha512"
"encoding/hex"
"errors"
"fmt"
"io"
@Zenithar
Zenithar / musig.go
Last active July 3, 2023 15:34
Schnorr signature aggregation with MuSig in Go.
package main
import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"crypto/sha256"
"fmt"
"math/big"
"os"
@Zenithar
Zenithar / GApps_remote_webhook_with_httpsig.gs
Last active June 28, 2023 12:17
Use HTTP Signature with Google Forms and a custom webhook.
const WEBHOOK_HOST = "<replace with your host>";
const WEBHOOK_PATH = "<replace with your path>";
function signAndSend(body) {
const signingKey = "-----BEGIN PRIVATE KEY-----\nREPLACE WITH YOUR PKCS8 ENCODED PRIVATE RSA KEY \n-----END PRIVATE KEY-----"
// Serialize payload request
const payload = JSON.stringify(body)
// Pack signature parameters