Coder Social home page Coder Social logo

go-randomness's Introduction

Randomness 二元序列随机性检测方法

Documentation GitHub go.mod Go version GitHub tag (latest SemVer)

在使用randomness前,请务必悉知 《randomness 免责声明》

快速入门

您可以通过下面命令安装randomness

go get -u github.com/Trisia/randomness

如何检测?

package main

import (
	"crypto/rand"
	"fmt"
	"github.com/Trisia/randomness"
)

func main() {
	// 产生随机数序列
	n := 1000_000
	buf := make([]byte, n/8)
	_, _ = rand.Read(buf)
	// 转换为字节数组
	bits := randomness.B2bitArr(buf)

	// 运行测试组
	p, _ := randomness.PokerTest(bits)
	fmt.Printf("扑克检测 n: 1000000, P-value: %f\n", p)
}

randomness 实现了 《GM/T 0025-2014 SSL VPN 网关产品规范》 5.4.4.3 随机数发生器 4个不同应用阶段的随机数检测:

使用方法见 测试用例

如果您的处理含有多个核心你可以使用Fast系列的API来加速检测,见 测试用例

概述

检测规范:

在 GM/T 0005-2021 中在 样本通过率判定 的基础上,增加了 样本均匀性判定 作为检测通过判定依据,详见 GM/T 0005-2021 6.3。

目前 randomness 已经升级至《GM/T 0005-2021 随机性检测规范》。

该工具库实现了《GM/T 0005-2021 随机性检测规范》中描述的15种随机性检测方法:

检测参数说明:

  • 样本长度:10^6比特
  • 显著水平:α = 0.01
  • 样本均匀性分布检测的显著性水平: ατ = 0.0001
  • 子区间数量: k = 10

各算法检测参数如下:

序号 检测项目 参数
1 单比特频数检测 -
2 块内频数检测 m = 10000
3 扑克检测 m = 4,8
4 重叠子序列检测 m = 3,5
5 游程总数检测 -
6 游程分布检测 -
7 块内最大游程检测 m = 10000
8 二元推导检测 k = 3,7
9 自相关检测 d = 1,2,8,16
10 矩阵秩检测 -
11 累加和检测 -
12 近似熵检测 m = 2,5
13 线型复杂度检测 m = 500,1000
14 Maurer通用统计检测 L=7,Q=1280
15 离散傅里叶检测 -

工具

若您需要使用相关测试工具需要您手动编译程序,详见相应工具说明文档:

go-randomness's People

Contributors

emmansun avatar trisia avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.